I want to check remote folder's content, and determine if the particular file exists in this folder (I'm checking only by filename, so chill :D)
Example: I want to check if in the folder /testftp
contains a textfile.txt
file.
I'm doing this to get folder content:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("myftpaddress");
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
request.Credentials = new NetworkCredential("uid", "pass");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("Directory List Complete, status {0}", response.StatusDescription);
reader.Close();
response.Close();
it writes in console:
-rw-r--r-- 1 6668 userftp 91137 jul 16 23:20 file1.txt
-rw-r--r-- 1 468 userftp 137 jul 16 18:40 file2.swf
and it writes full stream response into console, how to get only file names? Is there an easier way?