Hi,

The FTP Server is in Passive mode. and below is the code that I have written.

FtpWebRequest reqFTP = null;
try
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpURL));
if (!string.IsNullOrEmpty(FTPUser) && !string.IsNullOrEmpty(FTPPassword))
{
reqFTP.Credentials = new NetworkCredential(FTPUser, FTPPassword);
}
reqFTP.Proxy = null;
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
StreamReader outputStream = new StreamReader(reqFTP.GetResponse().GetResponseStream());

string strFileName = null;
if (outputStream != null)
strFileName = outputStream.ReadLine();

}


This does picks up the files but at times (very rare) that even if the file is present in the FTP location the program is not able to get the file listing and I have to restart the service to make it work. I dont know why a restart is necessary. The default value of reqFTP.The default value of reqFTP.UsePassive is true, so I have not explicitly set it to true. Please advice, what could be the problem !!! (I want to avoid the restarting of Service to make it FTP work again.)


Regards,
MH