解压加上.gz文件

问题描述:

我是学生,我试图要解压​​的文件,GZ,但它提供了以下错误信息:解压加上.gz文件

enter image description here

陈述在gzip头一个神奇的数字是不正确的,在这里是代码,如果有任何1可以让我知道我在做什么错误

 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 

} 

这意味着它说什么。你认为gzip文件不是,并且不以0x1f 0x8b开头。

+0

马克,希望你做得很好。 引用我的查询时,我试图解压缩为压缩文件(.gz),它显示以下错误消息。 我不明白为什么会发生这种情况。 谢谢 Subiraj –