public static DateTime GetFileModifyDateTime(string ftpServerIP,string ftpFolder,string ftpUserID,string ftpPwd, string fileName)
{
FtpWebRequest reqFTP=null;
try
{
if (ftpFolder != "")
{
ftpFolder = ftpFolder.Replace("/", "").Replace("\\", "");
ftpFolder = "/" + ftpFolder;
}
string ftpPath = "ftp://" + ftpServerIP + ftpFolder + "/" + fileName;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpPath));
reqFTP.UseBinary = true;
//reqFTP.UsePassive = false;
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPwd);
reqFTP.Method = WebRequestMethods.Ftp.GetDateTimestamp;
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
DateTime dt = response.LastModified;
response.Close();
response = null;
reqFTP = null;
return dt;
}
catch (Exception ex)
{
throw ex;
}
}