tags:

views:

157

answers:

1

I have been trying to write a simple ftp client using c# in .NET 2.0 for 3 days now and am missing something. I I create an ftpWebRequest object and set all its properies.

string uri = host + remoteFile;
System.Net.FtpWebRequest ftp = (FtpWebRequest)(FtpWebRequest.Create(uri));
ftp.Credentials = new System.Net.NetworkCredential(username, password);
ftp.KeepAlive = false;
ftp.UseBinary = true;
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;

But when I go to get the stream, it fails...

System.IO.Stream strm = ftp.GetRequestStream();

Here is the error: "System.Net.WebException: The remote server returned an error: (501) Syntax error in parameters or arguments."

This method SHOULD return the stream I need to write to and many examples do exactly this. I'm not sure what I'm missing. My host looks like this: "ftp://myhostname/" and I've triple checked my credentials.

Please help!

A: 

may be ftp.UseBinary = true; is not supported by server?

Andrey
I just tried with ftp.UseBinary = false and received the error message.
donde
@donde i will tell you long but universal debugging method for such errors. go and download WireShark (http://www.wireshark.org/download.html) then enable it and filter by ftp. then take a look at what does your app really sends, then compare to specs and fix!
Andrey