Results 1 to 3 of 3

Thread: GZIP Data

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    116

    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

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    116

    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
  •  



Click Here to Expand Forum to Full Width