Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1.  public static void Decompress(FileInfo fi)
  2.         {
  3.             // Get the stream of the source file.
  4.             using (FileStream inFile = fi.OpenRead())
  5.             {
  6.                 // Get original file extension, for example
  7.                 // "doc" from report.doc.gz.
  8.                 string curFile = fi.FullName;
  9.                 string origName = curFile.Remove(curFile.Length -
  10.                         fi.Extension.Length);
  11.  
  12.                 //Create the decompressed file.
  13.                 using (FileStream outFile = File.Create(origName))
  14.                 {
  15.                     using (GZipStream Decompress = new GZipStream(inFile,
  16.                             CompressionMode.Decompress))
  17.                     {
  18.                         // Copy the decompression stream
  19.                         // into the output file.
  20.                         Decompress.CopyTo(outFile);
  21.                        
  22.                         Console.WriteLine("Decompressed: {0}", fi.Name);
  23.  
  24.                     }
  25.                 }
  26.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement