我正在使用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