Can any one suggest to me the best way to see if a file exists? File.Exists
is not working for me.
string abc = "me_label.deploy";
File.Exists(abc)
The file, abc
, is coming from Streamreader.ReadLine();
.
I even used the full path. I don't want to include files in my project. If I include it in my project it is working fine.
My code:
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create("me@localhost/"; + ab);
//ab=newfolder/newfolder1
ftp.Credentials = new NetworkCredential(user, pass);
ftp.Method = WebRequestMethods.Ftp.ListDirectory;
StreamReader sr = new StreamReader(ftp.GetResponse().GetResponseStream());
StringBuilder result = new StringBuilder();
string abc = sr.ReadLine();
while (abc != null)
{
result.Append(abc);
//abc=file
result.Append("\n");
if (File.Exists(ab+abc))
{
//file
}
}