FTP client and national characters

Hi!

I'm writing an FTP client in VB.NET for educational purpose, so using an third party FTP client is not an option.
I'm having problem with sending the CWD command (Change Working Directory) to the FTP Server running IIS 6.
It works as expected with non-national characters, but when i try to change to a directory with national characters in the name, it doesn't work!
The server replies with code 550, file not found.

I've tried sending the command and directory name encoded in both UTF-7 and UTF-8, without success.
How do i make this work with national characters?

Any help appreciated!

Regards
Kristoffer
CyberStoffeAsked:
Who is Participating?
 
AvonWyssCommented:
Turning the server into UTF8 mode (RFC-2640 compliant) would be using the
OPTS UTF8 ON
command. The server should return 220 UTF8 OPTS ON (or so) if supported (can be queried using FEAT). Afterwards, all textual data (dir/file names, dir listings, etc.) will be UTF8.

If that does not work, I'd suggest to use Encoding.Default - which is usually the ISO-8859-1 in Europe. I know that there is a risk that this does not match the server encoding, but the chances are good that it will work with FTP servers using English charsets as well as with geographically close FTP servers using the same (or a similar) encoding.
0
 
andrewharrisCommented:
DOes the IIS Server have the applicable character set installed?

Andrew
0
 
Bob LearnedCommented:
Do other ways (like in a NT command prompt FTP session) accept the national characters?

Bob
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
CyberStoffeAuthor Commented:
andrewharris:
Don't know if the IIS Server has the applicable character set installed. Where do I check it?

TheLearnedOne:
It doesn't work in a NT command prompt FTP session, but other FTP clients are able to change to the directory with national characters.

/Kristoffer
0
 
Bob LearnedCommented:
Do you have anything that can shed a little more light on the situation?  Sample code, FTP site address, etc.?

Bob
0
 
CyberStoffeAuthor Commented:
The part of the code where I send the command to the FTP Server looks like this:

    Dim command As String = "CWD Images" & vbNewLine
    Dim buffer() As Byte = System.Text.Encoding.ASCII.GetBytes(command)
    Dim stream As NetworkStream = TcpClient.GetStream()

    stream.Write(buffer, 0, buffer.Length)

The FTP Server is on my local network and is running IIS 6 on Windows Server 2003.
The language version of Windows Server is swedish, and i'm having problem with changing to a directory with a swedish character in the directory name. It works with IE and other FTP Clients, bot not with the code above and not with the FTP command prompt utility.

In the response from the server (550 File not found), the national character is replaced with a question mark.

/Kristoffer
0
 
andrewharrisCommented:
Just out of curiosity, what do you get from PWD on the dir that contains the dir with the swedish chars?

Andrew
0
 
CyberStoffeAuthor Commented:
I managed to get the right characters back in the server response by using UTF7 encoding when I convert the byte array to a string.
No question marks anymore.

But it still says "550 File not found" when i send a CWD command encoded in UTF7.
Enclosing the directory name in double quotes doesn't make any difference.

If I send a LIST command, the directory list returned looks OK.
The national characters are displayed correctly.

/Kristoffer
0
 
CyberStoffeAuthor Commented:
Thanks for your help, AvonWyss!

Encoding.Default did the trick!
I also tried to send OPTS UTF8 ON to the server, but it responded "501 option not supported".

/Kristoffer
0
 
AvonWyssCommented:
Perfect. Hopefully, more servers will support the UTF8 option in the future, because this gets rid of endcoding issues for good...
0
 
CyberStoffeAuthor Commented:
...and of course thanks to anyone else who have tried to help me!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.