1

I'm a student I'm trying to unzip a gz file but it gives following error message:

enter image description here

Stating the magic number in GZip header is not correct, here is the code, I'really thannk full if any1 could let me know what mistake I'm doing

        FileInfo fileToDecompress = new FileInfo(dirpath);
        {
            Decompress(fileToDecompress);
        }

        Dts.TaskResult = (int)ScriptResults.Success;
    }

    public static void Decompress(FileInfo fileToDecompress)
    {
        using (FileStream originalFileStream = fileToDecompress.OpenRead())
        {
            string currentFileName = fileToDecompress.FullName;
            string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length);

            using (FileStream decompressedFileStream = File.Create(newFileName))
            {
                using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress,true))
                {
                    decompressionStream.CopyTo(decompressedFileStream);
                    Console.WriteLine("Decompressed: {0}", fileToDecompress.Name);
                }
            }
        }
    }

    #region ScriptResults declaration
    /// <summary>
    /// This enum provides a convenient shorthand within the scope of this class for setting the
    /// result of the script.
    /// 
    /// This code was generated automatically.
    /// </summary>
    enum ScriptResults
    {
        Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
        Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    };
    #endregion

}
Laur Ivan
  • 4,117
  • 3
  • 38
  • 62

1 Answers1

0

That means what it says. What you think is a gzip file is not, and does not start with 0x1f 0x8b.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • Hello Mark, Hope you're doing well. Refernce to my query while I was trying uncompresed as compressed file(.gz), it showed following error message. I couldn't figure out why is this happening. Thanks Subiraj – Subiraj Rathore Mar 02 '17 at 10:08