FtpWebRequest webReq;
webReq = (FtpWebRequest)FtpWebRequest.Create(
new
Uri(updateFileUrl));
FtpWebResponse res;
res = (FtpWebResponse)req.GetResponse();
異常:出現“webReq.ContentType”引發了“System.NotSupportedException”類型的異常
“webReq.PreAuthenticate”引發了“System.NotSupportedException”類型的異常
“webReq.UseDefaultCredentials”引發了“System.NotSupportedException”類型的異常
“res.ContentType”引發了“System.NotSupportedException”類型的異常
“res.PreAuthenticate”引發了“System.NotSupportedException”類型的異常
“res.UseDefaultCredentials”引發了“System.NotSupportedException”類型的異常
導致的結果是res取不到值。這是什么原因引起的啊?該如何解決?
“webReq.PreAuthenticate”引發了“System.NotSupportedException”類型的異常
“webReq.UseDefaultCredentials”引發了“System.NotSupportedException”類型的異常
“res.ContentType”引發了“System.NotSupportedException”類型的異常
“res.PreAuthenticate”引發了“System.NotSupportedException”類型的異常
“res.UseDefaultCredentials”引發了“System.NotSupportedException”類型的異常
導致的結果是res取不到值。這是什么原因引起的啊?該如何解決?
搞了這么久,終於知道為什么了。這三個異常存在是正常的。我的程序需要使用ContentLength屬性,因為是直接從http的改過來的,FTP的不能直接使用ContentLength屬性,需要將Method改為WebRequestMethods.Ftp.GetFileSize,才能使用ContentLength屬性。原因是在客戶端中FtpWebRequest是忽略ContentLength這個屬性的。
原文出自:http://bbs.csdn.net/topics/380034923