Link to home
Start Free TrialLog in
Avatar of mfb022800
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");

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mfb022800
mfb022800

ASKER

Thanks, I followed the link but can you show me the code change or explain to me how I would fit that into my code?  
Remove the .Proxy = null line
When that line is commented out the app displays the following:
The requested ftp command is not supported when using HTTP proxy
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.