I am trying to use DeflateStream to inflate data from a web server. for some reason though, the byte array my function returns contains several null characters instead of whatever they are supposed to be. eg(space represents a null char)
ge 603-595568599 _web : msg
Im not sure what im doing wrong. Here is my decompress function:
using (FileStream inFile = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
using (DeflateStream Decompress = new DeflateStream(inFile, CompressionMode.Decompress, true))
{
//Decompress.Flush();
using (StreamReader reader = new StreamReader(Decompress))
{
byte[] temp = Encoding.UTF8.GetBytes(reader.ReadToEnd());
for (int i = 0; i < temp.Length; i++)
{
if (temp[i] < 10) temp[i] = 0x20;
}
r0 = Encoding.UTF8.GetString(temp);
}
}
}
Am I doing something wrong? what would/could be the cause of this?
ETA: using example code from the msdn article produces the same results
using (FileStream inFile = new FileStream(filename, FileMode.Open, FileAccess.Read))
{
using (FileStream decompressedFileStream = File.Create("packet.txt"))
{
using (DeflateStream decompressionStream = new DeflateStream(inFile, CompressionMode.Decompress))
{
decompressionStream.CopyTo(decompressedFileStream);
r3=string.Format("Decompressed: {0}", "packet");
}
}
}
here goes an example data
42 58 51 8C 6E 85 51 BC 31 40 04 ED 28 48 2C 06 A8 B8 3C BF 28 C5 AE 5A 2D B1 20 BF D8 3A 1B 42 59 41 28 33 43 33 03 03 13 D3 78 13 23 0B 73 53 CB A4 B4 34 D3 B4 34 03 0B 53 0B 93 B4 A4 34 8B A4 24 E3 14 D3 54 43 73 13 B3 54 23 4B 83 24 D3 E4 34 13 88 AE 5A 1B 7D B8 B1 B8 3D 51 94 5A 9C 5F 5A 94 9C 6A 57 91 99 96 66 A3 0F E7 A2 F8 0E 00 00 00 FF FF