zoukankan      html  css  js  c++  java
  • C#获取ftp文件最后修改时间

    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;
      }  
      }

  • 相关阅读:
    使用canvas技术在网页上绘制鲜花
    java连接Access数据库
    L2-009. 抢红包
    L2-008. 最长对称子串
    L1-032. Left-pad
    L1-016. 查验身份证
    L1-005. 考试座位号
    L1-030. 一帮一
    L1-023. 输出GPLT
    L1-028. 判断素数
  • 原文地址:https://www.cnblogs.com/hyruur/p/3511626.html
Copyright © 2011-2022 走看看