Decompress code in C#

This blog shows on how to do a decompress C# code that is already compressed.



string compressedFile =
    "Document.zip";
string originalFileName =
    "Document.doc";

using (FileStream zipFile =
    new FileStream(compressedFile,
        FileMode.Open, FileAccess.Read))
using (FileStream originalFile =
    new FileStream(originalFileName,
        FileMode.Create, FileAccess.Write))
using (GZipStream alg =
    new GZipStream(zipFile, CompressionMode.Decompress))
{
    while (true)
    {
        byte[] buffer = new byte[100];
        int bytesRead = alg.Read(buffer, 0, buffer.Length);
        originalFile.Write(buffer, 0, returnedBytes);
        if (bytesRead != buffer.Length)
            break;
    }
}