Issue downloading file with special characters in the filename

Jun 17, 2014 at 11:38 AM
Hi.

I'm running version 1.0.5268.24683 and trying to download a file that has some special characters in the filename. FtpClient is throwing an exception:
System.Net.FtpClient.FtpCommandException: /TEST_TEST/Test/æøå.txt: No such file or directory.
   at System.Net.FtpClient.FtpClient.OpenPassiveDataStream(FtpDataConnectionType type, String command, Int64 restart)
   at System.Net.FtpClient.FtpClient.OpenDataStream(String command, Int64 restart)
   at System.Net.FtpClient.FtpClient.OpenRead(String path, FtpDataType type, Int64 restart)
Tracing shows that the file is actually there:
LIST /TEST_TEST/Test
150 Opening BINARY mode data connection for 'file list'.
-rwxrwxrwx   1 admin    users         4408858 Jun 17 09:51 S401 N-GB - 24_05_05.pdf
-rwxrwxrwx   1 admin    users              18 Jun 17 09:51 fil
-rwxrwxrwx   1 admin    users              24 Jun 17 13:09 æøå.txt

...

Text encoding: System.Text.UTF8Encoding
PWD
257 "/" is current directory.
CWD /
250 CWD command successful.
TYPE I
200 Type set to I.
SIZE /TEST_TEST/Test/æøå.txt
550 /TEST_TEST/Test/æøå.txt: No such file or directory.
I'm thinking this has something to do with encoding, but I can't figure out how to get it working. The FTP-server seems to be running UTF-8.

Can anyone help me resolve this?
Jun 17, 2014 at 12:22 PM
Additional information:

I'm only getting this error when connecting to a Synology FTP server. When connecting to a ProFTP server FtpClient has no problems handling the special characters.
Coordinator
Jun 17, 2014 at 12:57 PM
Please post the full trace from the Synology NAS. I don't have access to one for testing so I'll have to do some googling and see if other people are having encoding issues with them.

Also, please try another piece of software such as FileZilla client or something else and see if it has the same issue.
Jun 17, 2014 at 1:18 PM
I've tried running the same program using an older version of FtpClient and I didn't experience the issue. The old working version was 1.0.5064.19175.

Downloading through FileZilla works fine.

I'll try getting the server log for you (if I figure out how I can get a detailed log).
Coordinator
Jun 17, 2014 at 1:21 PM
Just post the trace from System.Net.FtpClient. See the Debug.cs example on how to add TraceListener objects for logging the transaction. Other things are logged such as the encoding System.Net.FtpClient is using, for example. I just want to look through it to see if there is any clue as to what might be happening. I'm basically running blind, I can't help fix it if I don't know what exactly is broken with System.Net.FtpClient and Synology's FTP daemon.
Jun 17, 2014 at 1:35 PM
Trace:
220 FTP1 FTP server ready.
USER admin
331 Password required for admin.
PASS <omitted>
230 User admin logged in.
FEAT
211- Extensions supported:
 AUTH TLS
 PBSZ
 PROT
 SIZE
 MDTM
 MFMT
 REST STREAM
 UTF8
211 End.
OPTS UTF8 ON
200 OK, UTF-8 enabled
Text encoding: System.Text.UTF8Encoding
Disposing FtpClient object...
Disposing FtpClient object...
Disposing FtpClient object...
220 FTP1 FTP server ready.
USER admin
331 Password required for admin.
PASS <omitted>
230 User admin logged in.
FEAT
211- Extensions supported:
 AUTH TLS
 PBSZ
 PROT
 SIZE
 MDTM
 MFMT
 REST STREAM
 UTF8
211 End.
OPTS UTF8 ON
200 OK, UTF-8 enabled
Text encoding: System.Text.UTF8Encoding
PWD
257 "/" is current directory.
CWD TEST_TEST
250 CWD command successful.
CWD /
250 CWD command successful.
PWD
257 "/" is current directory.
CWD /TEST_TEST/Test
250 CWD command successful.
CWD /
250 CWD command successful.
PWD
257 "/" is current directory.
TYPE I
200 Type set to I.
PASV
227 Entering Passive Mode (10,233,15,12,217,4)
LIST /TEST_TEST/Test
150 Opening BINARY mode data connection for 'file list'.
-rw-rw-rw-   1 admin    users              24 Jun 17 14:37 æøå.txt
226 Transfer complete.
Disposing FtpSocketStream...
Ignoring modified date because MDTM feature is present. If you aren't already, pass FtpListOption.Modify or FtpListOption.SizeModify to GetListing() to retrieve the modification time.
æøå.txt
PWD
257 "/" is current directory.
CWD /TEST_TEST/Test2
250 CWD command successful.
CWD /
250 CWD command successful.
PWD
257 "/" is current directory.
TYPE I
200 Type set to I.
PASV
227 Entering Passive Mode (10,233,15,12,217,5)
LIST /TEST_TEST/Test2
150 Opening BINARY mode data connection for 'file list'.
226 Transfer complete.
Disposing FtpSocketStream...
220 FTP1 FTP server ready.
USER admin
331 Password required for admin.
PASS <omitted>
230 User admin logged in.
FEAT
211- Extensions supported:
 AUTH TLS
 PBSZ
 PROT
 SIZE
 MDTM
 MFMT
 REST STREAM
 UTF8
211 End.
OPTS UTF8 ON
200 OK, UTF-8 enabled
Text encoding: System.Text.UTF8Encoding
220 FTP1 FTP server ready.
USER admin
331 Password required for admin.
PASS <omitted>
230 User admin logged in.
Text encoding: System.Text.UTF8Encoding
PWD
257 "/" is current directory.
CWD /
250 CWD command successful.
TYPE I
200 Type set to I.
SIZE /TEST_TEST/Test/æøå.txt
550 /TEST_TEST/Test2/æøå.txt: No such file or directory.
PASV
227 Entering Passive Mode (10,233,15,12,217,10)
RETR /TEST_TEST/Test/æøå.txt
550 /TEST_TEST/Test/æøå.txt: No such file or directory.
QUIT
221 Goodbye. You uploaded 0 bytes and downloaded 0 bytes.
Disposing FtpClient object...
Disposing FtpSocketStream...
Coordinator
Jun 17, 2014 at 1:41 PM
Thanks, someone just opened a new ticket with the same problem and their description matches what I see in the transaction log, UTF8 isn't being configured on cloned connections (default behavior, EnableThreadSafeDataChannels = true). I'm about to work on it now. Will let you know when it's fixed.
Coordinator
Jun 17, 2014 at 2:05 PM
The latest releases send the OPTS UTF8 ON command for cloned connections now. Please give it a run and let me know the results.
Marked as answer by sigurdhj on 6/17/2014 at 8:24 AM
Jun 17, 2014 at 3:24 PM
Seems to be working fine now.

Thanks a lot. :)
Coordinator
Jun 17, 2014 at 3:25 PM
Great, glad we got it sorted out.