C#
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 ?
public static void Decomprees (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);
}
}
}
}
Rajanikant HawaldarRank #108 · 20.5K reputationPosted Dec 21, 2019, 8:27 PM EST