FTP経由でファイルを取得する次のコードがあります。
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);
}
これはほとんどの場合に機能しますが、例外が発生するクライアント マシンが 1 つあります。
The remote server returned an error 403: Forbidden
なぜこれが当てはまるのか、誰か教えてもらえますか?すべてのクライアントで実行されているのとまったく同じコードですか (同じユーザー名とパスワードを含む)?