我在IIS 7中启用了Windows ftp,并且能够通过ftp://user:password@RBDRMSNMVM01
进行连接。但是我在C#snipet下面尝试了同样的方法,但我无法传输文件。
在GetRequestStream()方法调用失败了,它说“无法连接到远程服务器”
strUserName = FTP Windows Server login user id
strPwd = FTP Windows Server login password
FtpWebRequest request = null;
FileStream fs = null;
Stream reqStream = null;
request = (FtpWebRequest)FtpWebRequest.Create(strFTPConnString);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(strUserName, strPwd);
reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
Any help would be greatly appreciated !!!
答案 0 :(得分:0)
请检查strFTPConnString是否具有正确的服务器地址。
同时检查端口是否被防火墙阻止。