S
squall
Hi,
I have to upload files on a ftp server through a ftp proxy with
Dotnet.
I have a 'System.InvalidOperationException' with this message : "The
requested FTP command is not supported when using HTTP proxy". Is
there a solution to use a FTP proxy and not a HTTP proxy ?
Thanks
Marc
My code (in CLI/C++, but the same in C#) :
// Get the object used to communicate with the server.
FtpWebRequest^ request = (FtpWebRequest^)WebRequest::Create("ftp://
xxx.xxx.com"); // Uri of ftp server
request->Method = WebRequestMethods::Ftp::UploadFile;
// FTP Proxy
request->Proxy = gcnew WebProxy("ftpProxyHostname", 21);
request->Credentials = gcnew
NetworkCredential("ftpServerUser","password");
// Copy the contents of the file to the request stream.
StreamReader^ sourceStream = gcnew StreamReader(exportDirectory +
zipName);
request->ContentLength = fileContents->Length;
Stream^ requestStream = request->GetRequestStream();
requestStream->Write(fileContents, 0, fileContents->Length);
requestStream->Close();
FtpWebResponse^ response = (FtpWebResponse^)request->GetResponse();
I have to upload files on a ftp server through a ftp proxy with
Dotnet.
I have a 'System.InvalidOperationException' with this message : "The
requested FTP command is not supported when using HTTP proxy". Is
there a solution to use a FTP proxy and not a HTTP proxy ?
Thanks
Marc
My code (in CLI/C++, but the same in C#) :
// Get the object used to communicate with the server.
FtpWebRequest^ request = (FtpWebRequest^)WebRequest::Create("ftp://
xxx.xxx.com"); // Uri of ftp server
request->Method = WebRequestMethods::Ftp::UploadFile;
// FTP Proxy
request->Proxy = gcnew WebProxy("ftpProxyHostname", 21);
request->Credentials = gcnew
NetworkCredential("ftpServerUser","password");
// Copy the contents of the file to the request stream.
StreamReader^ sourceStream = gcnew StreamReader(exportDirectory +
zipName);
sourceStream->Close();array said:ReadToEnd());
request->ContentLength = fileContents->Length;
Stream^ requestStream = request->GetRequestStream();
requestStream->Write(fileContents, 0, fileContents->Length);
requestStream->Close();
FtpWebResponse^ response = (FtpWebResponse^)request->GetResponse();