简体   繁体   中英

Uploading a .txt file to an FTP server

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 ?

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM