0

I am trying to upload a .txt file to an ftp server using this example http://msdn.microsoft.com/en-us/library/ms229715.aspx

I get a "The requested URI is invalid for this FTP command" error . When i change request.method from WebRequestMethods.Ftp.UploadFile to WebRequestMethods.Ftp.UploadFileWithUniqueName it works..

But this way a .tmp file is created with a random name. Any suggestions on how to upload the txt ?

2
  • And this sounds like the file already exists on the server. By doing "WithUniqueName" it does not overwrite the file.
    – gunr2171
    Oct 10, 2013 at 23:02
  • It is not similar. I am not asking the same thing.
    – jayt.dev
    Oct 10, 2013 at 23:47

1 Answer 1

0

I pasted the code from the link, and got the same problem.

Since I created the ftp server, the problem was that the user didn't have delete permissions, so the file couldn't be overridden nor appended.

Once I've set the permissions to do that, the code works, and I can see the file uploaded. (also tried appending, and it works as well).

Can you make sure you have the permissions to write to the FTP? If you can do this once only, you probably have read/write permissions, but no delete, so it fails. It'll be easy to test, just give a new name to the file and see what happens

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://ftp_address/new_file_name_here");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.