That's how I get file list from FTP:
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(url);
ftpRequest.Credentials = new NetworkCredential(FtpUser, Password);
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
List<string> result = new List<string>();
using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
{
string line = streamReader.ReadLine();
while (!string.IsNullOrEmpty(line))
{
result.Add(line);
line = streamReader.ReadLine();
}
}
And if there are files with folders there on ftp like:
folder01_name
folder02_name
image.png
text.txt
Result will contain strings for all this names:
folder01_name
folder02_name
image.png
text.txt
I need to get files only somehow. Of course I can try to filter it somehow but it's not a good solution and sometimes files become without resolution, so it's very hard to find differense between file and folder names.
How do I solve it?