我有下面的代碼來獲取通過FTP文件:C#的FtpWebRequest錯誤403
try
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverPath);
request.KeepAlive = true;
request.UsePassive = true;
request.UseBinary = true;
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(username, password);
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
using (StreamWriter destination = new StreamWriter(destinationFile))
{
destination.Write(reader.ReadToEnd());
destination.Flush();
}
return 0;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
這在大多數情況下,但我有一個客戶端機器在那裏我得到一個異常:
The remote server returned an error 403: Forbidden
有誰能告訴我爲什麼會出現這種情況?它與所有客戶端上運行的代碼完全相同(包括相同的用戶名和密碼)?
如果使用Internet Explorer從發生故障的計算機發出FTP請求,會發生什麼情況? – 2010-07-01 08:09:27
從IE – 2010-07-01 12:55:25