I'm trying to send a file using ftp. I have the following code:
string server = "x.x.x.x"; // Just the IP Address
FileStream stream = File.OpenRead(filename);
byte[] buffer = new byte[stream.Length];
WebRequest request = WebRequest.Create("ftp://" + server);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(username, password);
Stream reqStream = request.GetRequestStream(); // This line fails
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
But when I run it, I get the following error:
The requested URI is invalid for this FTP command.
Please can anyone tell me why? Am I using this incorrectly?