我已经在 IIS 7 中启用了 windows ftp 并且能够通过ftp://user:password@RBDRMSNMVM01
. 但是我通过下面的 C# 片段尝试了相同的方法,但我无法传输文件。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 !!!