Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm receiving "The requested URI is invalid for this FTP command" error when attempting to upload any file that contains a "#" in the filename. All other files upload without any issues. If I remove the #, the files upload fine, but this isn't an option as it's required for numerous clients.

What I have tried:

I've checked the full URI & it's correct...

ftp://path-to-server/folder/#1.jpg

I've tested uploading the files using Windows FTP & Filezilla without any problems. For some reason, that I can't figure out, FTPWebRequest doesn't like # in the filenames.
Posted
Updated 3-Apr-18 17:59pm
Comments
Peter_in_2780 3-Apr-18 0:12am    
Can you try encoding the # as # ? Something is probably treating it as an HTML tag reference or as a (broken) URL encoding.
(grrr took me 3 goes to get this encoded right!)
Shane_Beggs 3-Apr-18 9:45am    
Thanks heaps! I ended up using WebUtlity.UrlEncode(ftp://path-to-server/folder/#1.jpg) which works a treat!
Peter_in_2780 3-Apr-18 23:52pm    
Great! I'll turn my comment into an answer. Then the question will show as answered, for others to reference.

1 solution

Since you are using a web request, the filename is being treated as a URL. The character # is a special character in URLs, and needs to be encoded, such as # Other special characters will need similar encoding.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900