473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to specify encoding for file transfer from FTP?

I noticed that when i read files from an FTP
using FtpWebRequest, the file names using
swedish characters seem not to be interpreted
correctly. I get a square, instead.

After having looked for an hour or so, i gave
up - where do i specify the encoding for the
communication with the FTP server?

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Jul 28 '08 #1
4 4493
K Viltersten wrote:
I noticed that when i read files from an FTP
using FtpWebRequest, the file names using
swedish characters seem not to be interpreted
correctly. I get a square, instead.

After having looked for an hour or so, i gave
up - where do i specify the encoding for the
communication with the FTP server?
If you get a file binary with Stream's then you do not
care about encoding.

If you get a file text with StreamReader and StreamWriter
then those two classes has constructors that takes an
Encoding as argument.

Arne
Jul 28 '08 #2
>I noticed that when i read files from an FTP
>using FtpWebRequest, the file names using
swedish characters seem not to be interpreted
correctly. I get a square, instead.

After having looked for an hour or so, i gave
up - where do i specify the encoding for the
communication with the FTP server?

If you get a file binary with Stream's then you do not
care about encoding.

If you get a file text with StreamReader and StreamWriter
then those two classes has constructors that takes an
Encoding as argument.
Thanks. I still have two problems. I'd go with
the binary style, however, i'm reading the list
of all files using
WebRequestMethods.Ftp.ListDirectory;
and i don't know the size of the result. What
size of the buffer need i to declare?

Also, when i tried to read the contents of the
stream, i got an exception.
System.Net.ProtocolViolationException
What to do?

My hypothesis is that i can't read binary using
ListDirectory method. Is that true?

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Jul 28 '08 #3
K Viltersten wrote:
>>I noticed that when i read files from an FTP
using FtpWebRequest, the file names using
swedish characters seem not to be interpreted
correctly. I get a square, instead.

After having looked for an hour or so, i gave
up - where do i specify the encoding for the
communication with the FTP server?
If you get a file binary with Stream's then you do not
care about encoding.

If you get a file text with StreamReader and StreamWriter
then those two classes has constructors that takes an
Encoding as argument.

Thanks. I still have two problems. I'd go with
the binary style, however, i'm reading the list
of all files using
WebRequestMethods.Ftp.ListDirectory;
and i don't know the size of the result. What
size of the buffer need i to declare?
You don't.

You will need to read to end of file.

StreamReader and ReadToEnd is easy.
Also, when i tried to read the contents of the
stream, i got an exception.
System.Net.ProtocolViolationException
What to do?

My hypothesis is that i can't read binary using
ListDirectory method. Is that true?
I think so.

Arne
Aug 2 '08 #4
>Thanks. I still have two problems. I'd go with
>the binary style, however, i'm reading the list
of all files using
WebRequestMethods.Ftp.ListDirectory;
and i don't know the size of the result. What
size of the buffer need i to declare?

You don't.

You will need to read to end of file.

StreamReader and ReadToEnd is easy.
>Also, when i tried to read the contents of the
stream, i got an exception.
System.Net.ProtocolViolationException
What to do?

My hypothesis is that i can't read binary using
ListDirectory method. Is that true?

I think so.
Thanks!

--
Regards
Konrad Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.
Aug 2 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Konrad Den Ende | last post by:
I've been looking around and i've been given some hints but i simply can't get to the bottom of it. How do i specify the character encoding for reading text froma file? -- Kindly Konrad...
0
by: David Bolen | last post by:
I've noticed that using set_charset() on an email.Message instance will not replace any existing Content-Transfer-Encoding header but will install one if it isn't yet present. Thus, if you...
38
by: lawrence | last post by:
I'm just now trying to give my site a character encoding of UTF-8. The site has been built in a hodge-podge way over the last 6 years. The validator tells me I've lots of characters that don't...
8
by: Xarky | last post by:
Hi, I am downloading a GIF file(as a mail attachement) with this file format, Content-Transfer-Encoding: base64; Now I am writing the downloaded data to a file with this technique: ...
4
by: A_StClaire_ | last post by:
hi, I am using the following code to download multiple file types from a server. .txt files transfer fine. however Word .doc files come through garbled and I don't know enough about encoding...
0
by: mubx2000 | last post by:
Hi , I'm looking for code (Symbian C++) that can do the following things: 1-Analyzing the (MIME) types (Content-typemContent-transfere-encoding,Mime Version,Conent Description). 2-Download...
0
by: Nobody | last post by:
I have an application that processes MIME messages. It reads a message from a file, looks for a text/html and text/plain parts in it, performs some processing on these parts, and outputs the new...
0
by: VeeraLakshmi | last post by:
I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.If the HTTP header contains Content-Length,am getting the content length as below:...
2
by: VeeraLakshmi | last post by:
Can anybody tell me how to get or read the value of transfer encoding. I got the HTTP Response header as "Transfer-Encoding: chunked".But i can't get the chunk size or the chunked data. Without...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.