【问题标题】:The given Path's format is not supported when accessing the files in FTP访问 FTP 中的文件时,不支持给定路径的格式
【发布时间】:2015-05-05 07:06:09
【问题描述】:

这是我的代码;

string filedate = "ftp://72.242.29.132/TestArca/Test" +directories[i].ToString();
int j = filedate.IndexOf(":");
DateTime fileCreatedDate = File.GetCreationTime(filedate);

我在第三行遇到问题,因为不支持给定路径的格式。

【问题讨论】:

    标签: c#


    【解决方案1】:

    File.GetCreationTime 仅适用于文件。您正在尝试获取 ftp 资源的日期。 试试这样的:

    Retrieving creation date of file (FTP)

    【讨论】:

      【解决方案2】:

      我认为您编写它的方式对本地文件有效。我建议像这样:

      https://msdn.microsoft.com/en-us/library/system.net.ftpwebresponse.lastmodified%28v=vs.110%29.aspx

      并像这样修改代码

        string temp = response.StatusDescription;
            temp = temp.Substring(temp.LastIndexOf(" ") + 1);
            string FileCreationDateTime= temp.Substring(0, 4) + "-" + temp.Substring(4, 2) + "-" + temp.Substring(6, 2);
      

      【讨论】:

      • 但这会得到最后修改日期。用户想要获取文件的创建日期。
      猜你喜欢
      • 2014-11-19
      • 2011-11-13
      • 2012-04-21
      • 1970-01-01
      • 2014-12-08
      • 1970-01-01
      • 1970-01-01
      • 2017-09-14
      相关资源
      最近更新 更多