Hello all,

I am having a problem while setting encoding for stream/writer reader using c#.

I have to download text files using ftp and http requets.

The problem is that i dont know the encoding of text files.

i am using code below.

Stream readStream = new MemoryStream();
readStream= FTPwebResponse.GetResponseStream();
or
readStream = HTTPwebResponse.GetResponseStream();

then i will read it through stream reader

StreamReader reader = new StreamReader(readStream, Encoding.?????);
String responce = reader.ReadToEnd();

StreamWriter writeStream = new StreamWriter(FileNameWithPath, true, Encoding.????????);

writeStream.Write(responce);

here i dont know which encoding to use. if i dont use encoding i am getting sone unknown characters in some files. that are italian, spanish, arabic etc. some of these are comming fine but in some places i am getting boxes and question marks.

is there any way to detect encoding of stream ? so that i can use it for in stream reader/writer??

hope some one will help me out.

thanks in advance.

Best Regards,
Mansoor.