FTP download of file with '#' in filename

neosapien

Member
Joined
Jun 27, 2012
Messages
8
Programming Experience
1-3
Hello everyone
I am using ftpwebrequest to download files from an FTP site. It works perfectly till the point it encounters a file with # in its file name. Then it gives the error "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)." The files that I am trying to download are encrypted, so the file name is a bunch of special (but permitted) characters. I tried omitting different characters and confirmed that # is the problem. Has anyone come across something like this? If yes, any solutions? Thanks in advance.
 
Doesn't that replace the character from the uri altogether? Actually I tried it and it replaced the spaces and slashes as well with the % character. Then when it tries to download using the escaped uri, it can't find the file because now the uri does not match the actual file name. Am I doing this right? Can you give me a sample block?
 
I couldn't get the uri to accept my local host unfortunately.

I can download an ftp file with a "#" in the name by explicitly replacing the "#" with "%23" (hex equivalent) in the ftpfilepath string, I didn't use a uri.

VB.NET:
dim RemoteFilePath as String = "ftp://127.0.0.1/pic#1.jpg"

RemoteFilePath = RemoteFilePath.Replace("#", "%23")
FTPRequest = FtpWebRequest.Create(RemoteFilePath)
 
Last edited:
Back
Top