Abdalla Omran

Abdalla Omran

  • NA
  • 334
  • 32.3k

How could i check if the extract file from .gz is already in

Dec 18 2019 3:39 AM

This Code should decomprees the .gz extention files and it does . but i want to check if the file is already extracted

or the file is already exsosts .

How can I do that or check ?

  1. public static void Decomprees (FileInfo fileToDecompress)  
  2. {  
  3.  using (FileStream originalFileStream = fileToDecompress.OpenRead())  
  4. {  
  5.  string currentFileName = fileToDecompress.FullName;  
  6.  string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length);  
  7.  using (FileStream decompressedFileStream = File.Create(newFileName))  
  8.    {  
  9.     using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress))  
  10.     {  
  11.    decompressionStream.CopyTo(decompressedFileStream);  
  12.  }  
  13.  }  
  14.  }  
  15.   }  


Answers (1)