I am trying to build a list of all files on a ftp server.
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(remote);
request.Credentials = new NetworkCredential(userName, passWord);
request.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream());
List<string> files = new List<string>();
// Build List of all files
string line = streamReader.ReadLine();
while (!string.IsNullOrWhiteSpace(line))
{
files.Add(line);
line = streamReader.ReadLine();
}
streamReader.Close();
Now, the problem is, whe i use this list with the broken/incomplete file to download all the files with a Webclient, the code breaks when trying to download the incomplete file...
The remote server returned an error: (550) File unavailable (e.g., file not found, no access)
How can i skip these files when building the list?