我正在寫一個程序有點麻煩。該程序會檢查遠程ftp站點上的文件創建日期,如果它與今天的日期匹配,它將下載文件並將其上傳到另一個ftp站點。我收到以下錯誤,當我運行程序:問題與FtpWebRequest getDateTimestamp和DateTime
未處理的異常system.formatexception字符串未被識別爲有效的datetime
這裏是我使用創建日期FTP文件轉換爲datetime代碼
/* Get the Date/Time a File was Created */
string fileDateTime = DownloadftpClient.getFileCreatedDateTime("test.txt");
Console.WriteLine(fileDateTime);
DateTime dateFromString = DateTime.Parse(fileDateTime, System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat);
Console.WriteLine(dateFromString);
任何想法,我在做什麼錯在這裏?
有什麼'fileDateTime'字符串的內容? –
它應該是在ftp服務器上創建文件的日期。如果有幫助,我可以爲該行所指的類添加代碼。 –
是的,但字符串的實際內容是什麼?沒有內容的樣本,很難看到你需要做什麼來解析它。 –