mfb022800
asked on
FTP Upload Code fails but IE allows FTP Upload. Does MS Proxy Server prevent code from working?
I have a C# application to upload a file which returns the message "the remote name could not be resolved: ftp.xxxxx.com". This problem only exists with one of my customers and a few dozen others don't have the problem, the code works for them. This one customer can access ftp.xxxxx.com using IE but not with my code and they are using MS Proxy Server. Can MS Proxy server prevent this code from working but allows access using IE? What do I have to do to get this code to work?
string FTPAddress = "ftp://ftp.xxxxx.com";
string username = "valid username";
string password = "valid password";
//Create FTP request
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(FTPAddress + "/" + Path.GetFileName(filePath)));
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, password);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
request.Proxy = null;
//Load the file
FileStream stream = File.OpenRead(filePath);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
//Upload file
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
MessageBox.Show("Uploaded Successfully");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Remove the .Proxy = null line
ASKER
When that line is commented out the app displays the following:
The requested ftp command is not supported when using HTTP proxy
The requested ftp command is not supported when using HTTP proxy
ASKER
Thanks guys. This ftp proxy issue is more of a problem than I hoped it would be so I decided to use Web Services instead.
ASKER