How can I check if the file exists in my FTP server? I am getting an catch exception because sometimes the file does not exists.
DateTime now = DateTime.Now;
string repotroday = "report_" + now.Year.ToString() + "_" + now.Month.ToString() + "_" + now.Day.ToString() + ".csv";
WebClient client = new WebClient();
string url = "ftp://vps.myserver.com/" + repotroday;
client.Credentials = new NetworkCredential("SURE", "iRent@123");
string contents = client.DownloadString(url);
However, when I do not have the report in the FTP, it returns: The remote server returned an error: (550) File unavailable (e.g., file not found, no access)
Is there a way to check if the file exists before trying to download it?
Thanks