I am trying to get a list of files from FTP. but instead I am getting the name of the directory where the files are saved
List<string> file_names = new List<string>();
try
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Host + "Data");
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential(UserID, Password);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
string files = reader.ReadToEnd();
print(files); // prints "Data" instead of list of file names
file_names = files.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();
Debug.Log($"Directory List Complete, status {response.StatusDescription}");
reader.Close();
response.Close();
}
catch(WebException e)
{
print(e.Message + "\tCould not get files from server");
}
What am I doing wrong ?