views:

594

answers:

2

I am ftp'ing files from an external server, then deleting them on the external server, and one file failed because there was a space in the filename. I changed my ftp delete command to have quotes around the filename.

ftpStream.WriteLine("delete """ & FileToDelete & """")

But, are there other characters that a user might use in their filename creation, that my program will still choke on? I don't have any control what those filenames might be.

(I put a tag of SSIS and SQL Server, because I'm creating the ftp task on the fly, from an SSIS pakcage. OS on both sides are Win XP)

A: 

See section 5.3 of the FTP RFC (RFC 959). There is not actually any illegal characters, other than CrLf, that are illegal as part of the file name.

The problem is knowing what characters the destination server will choke on vs. illegal FTP characters. I'm guessing that besides space, there are not too many characters that will cause problem.s But I'm not an FTP expert.

JaredPar
+2  A: 

Any characters that are reserved by the file system won't be allowed. This usually includes spaces, commas, slashes, colons, quetion marks, double quotes, etc. But as JaredPar mentioned, space is probably the only universal offender since each file system has its own set of reserved characters that don't always overlap.

its a good idea to url encode any ftp or http paths. This will convert spaces to %20 which typically should be understood by the ftp server.

Soviut
Oh! that sounds like a good idea.
thursdaysgeek