More backoffice fun
This commit is contained in:
30
PartSource.Backoffice/Services/GZipService.cs
Normal file
30
PartSource.Backoffice/Services/GZipService.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace PartSource.Backoffice.Services
|
||||
{
|
||||
|
||||
public class GZipService
|
||||
{
|
||||
public static void Decompress(string path)
|
||||
{
|
||||
FileInfo fileToDecompress = new FileInfo(path);
|
||||
|
||||
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);
|
||||
Console.WriteLine($"Decompressed: {fileToDecompress.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user