none
How could i check if the extract file from .gz is already in directory exists ? RRS feed

  • Question

  • This code should decomprees the .gz extention file but i want to check if the file is already extracted or already exists 

    How can i check ? 

     
      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))
                        {
                            decompressionStream.CopyTo(decompressedFileStream);
    
                        }
                    }
                }
            }
    

    Wednesday, December 18, 2019 9:09 AM

Answers

All replies