Link to home
Start Free TrialLog in
Avatar of CyberStoffe
CyberStoffe

asked on

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
Avatar of andrewharris
andrewharris

DOes the IIS Server have the applicable character set installed?

Andrew
Avatar of Bob Learned
Do other ways (like in a NT command prompt FTP session) accept the national characters?

Bob
Avatar of CyberStoffe

ASKER

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
Do you have anything that can shed a little more light on the situation?  Sample code, FTP site address, etc.?

Bob
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
Just out of curiosity, what do you get from PWD on the dir that contains the dir with the swedish chars?

Andrew
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
ASKER CERTIFIED SOLUTION
Avatar of AvonWyss
AvonWyss
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Perfect. Hopefully, more servers will support the UTF8 option in the future, because this gets rid of endcoding issues for good...
...and of course thanks to anyone else who have tried to help me!