|
-
Jun 19th, 2006, 09:51 PM
#1
Thread Starter
Lively Member
GZIP Data
I'm parsing the Content-Length from a return header and grabbing that much data, which appears to be all of it, from the packets i receive. I then write it to a file like this:
Code:
byte[] strHTMLb = StrToByteArray(strParts[1]);
FileStream fs = File.Create(Environment.CurrentDirectory + @"\\gzipData.gz");
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(strHTMLb);
bw.Close();
fs.Close();
The problem is that it also says the magic number is wrong when i try to decompress the gzip information. I tested my decompression on actual gzip data and it works fine so i know it's something with either my parsing or writing to the file. If anyone has an idea of what i'm doing wrong that would be great. Thanks for any help
-
Jun 20th, 2006, 06:36 AM
#2
Re: GZIP Data
Your path is wrong for starters, either have "\\gzipData.gz" or @"\gzipData.gz" but not both.
You don't need the binary writer at all. The FileStream can write your byte array for you.
2005 has the GZipStream class, I suggest you give that a try.
I don't live here any more.
-
Jun 20th, 2006, 07:54 PM
#3
Thread Starter
Lively Member
Re: GZIP Data
thanks for the help.
if i put ‹ betwen 2 box characters at the beggining of my gzip data, when i open it in notepad, then it works until it gets to the crc check to see if the data is corrupted. I'm not sure how i can get it to work thoug. Note: ‹ is not <. Thanks for any help
Here's my string to byte array function, maybe i made an error there?
Code:
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|