?
Solved

FTP client and national characters

Posted on 2004-10-28
11
Medium Priority
?
632 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:CyberStoffe
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 4

Expert Comment

by:andrewharris
ID: 12442115
DOes the IIS Server have the applicable character set installed?

Andrew
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12443029
Do other ways (like in a NT command prompt FTP session) accept the national characters?

Bob
0
 

Author Comment

by:CyberStoffe
ID: 12444070
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 12446372
Do you have anything that can shed a little more light on the situation?  Sample code, FTP site address, etc.?

Bob
0
 

Author Comment

by:CyberStoffe
ID: 12446952
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
 
LVL 4

Expert Comment

by:andrewharris
ID: 12449493
Just out of curiosity, what do you get from PWD on the dir that contains the dir with the swedish chars?

Andrew
0
 

Author Comment

by:CyberStoffe
ID: 12449764
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
 
LVL 14

Accepted Solution

by:
AvonWyss earned 1000 total points
ID: 12453960
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
 

Author Comment

by:CyberStoffe
ID: 12454025
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
 
LVL 14

Expert Comment

by:AvonWyss
ID: 12454030
Perfect. Hopefully, more servers will support the UTF8 option in the future, because this gets rid of endcoding issues for good...
0
 

Author Comment

by:CyberStoffe
ID: 12454033
...and of course thanks to anyone else who have tried to help me!
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question