A
A_StClaire_
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 to understand
why.
the object 's' is a Mentalis.org component that, for all purposes here,
is a System.Net.Socket. the line I commented out is one that
hard-codes the encoding to 'ASCII' which I assume would only hurt me.
I know I am sending the request correctly. can anyone see how or if I
am misusing the System.Text.Encoding function?
thx, all
byte[] buffer = new byte[4096];
int ret = s.Receive(buffer);
FileStream fs = new FileStream(@"C:\sample.doc", FileMode.Append,
FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
while(ret != 0)
{
// string sResponse = Encoding.ASCII.GetString(buffer, 0, ret);
string sResponse =
System.Text.Encoding.GetEncoding(1252).GetString(buffer);
bw.Write(sResponse);
if(s.Available != 0)
ret = s.Receive(buffer);
else
ret = 0;
}
bw.Close();
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 to understand
why.
the object 's' is a Mentalis.org component that, for all purposes here,
is a System.Net.Socket. the line I commented out is one that
hard-codes the encoding to 'ASCII' which I assume would only hurt me.
I know I am sending the request correctly. can anyone see how or if I
am misusing the System.Text.Encoding function?
thx, all
byte[] buffer = new byte[4096];
int ret = s.Receive(buffer);
FileStream fs = new FileStream(@"C:\sample.doc", FileMode.Append,
FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
while(ret != 0)
{
// string sResponse = Encoding.ASCII.GetString(buffer, 0, ret);
string sResponse =
System.Text.Encoding.GetEncoding(1252).GetString(buffer);
bw.Write(sResponse);
if(s.Available != 0)
ret = s.Receive(buffer);
else
ret = 0;
}
bw.Close();