Smaug
Smaug

Reputation: 2673

Windows FTP Connection says Unable to connect to the remote server

I've enabled windows ftp in IIS 7 and able to connect through ftp://user:password@RBDRMSNMVM01. However I tried the same through below C# snipet but I could not able to transfer the file. It was failed at GetRequestStream() method call, which was saying "Unable to connect to the remote server"

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 !!!

Upvotes: 0

Views: 2176

Answers (1)

Ankur Singhal
Ankur Singhal

Reputation: 71

Please Check whether strFTPConnString has the correct server address.

Also check if ports are being blocked by firewall.

Upvotes: 1

Related Questions