我正在使用c#.net編寫Windows應用程序。 我正在使用FTPwebrequest類上傳ftp.it文件,在應用程序和Internet之間沒有代理時工作正常。但它在代理中不起作用。使用FTP上傳文件的問題
FtpWebRequest reqFTP;
如果我使用reqFTP.Proxy=new webproxy("proxyservername",21);
那麼它會顯示錯誤消息「FTP命令doen't在HTTP代理支持」。
我的代碼是這樣的
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create("ftp://uri");
reqFTP.Credentials = new NetworkCredential("username", "pwd");
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true;
reqFTP.UsePassive = true;
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
FileStream fs = fileInf.OpenRead();
Stream strm = reqFTP.GetRequestStream();
contentLen = fs.Read(buff, 0, buffLength);
while (contentLen != 0)
{
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
prbUpload.Value += contentLen;
}
strm.Close();
fs.Close();
如何以編程方式爲ftp配置代理服務器。 – dhanya 2011-01-06 11:39:32