?????? ? ???????? GZip

?????

API Aspose.ZIP ??? .NET ??? ????? ?????????? ?? ???????? ???????? GZip ? ????? ????????? ??? ???????????? ??????????????? ????-??? ???????? ????????.�API Aspose.ZIP ?????�????� GZipArchive�??? ?????? ? ???????? GZip. ??? ???? ????? ????? ?????? ??? ????????? ???????? ??? ????????.

???????? ????????? Gzip ?????????? ?? ????????? DEFLATE, ???? ? ??????????? ????????? LZ77 ? ????????.

???????? ????

? ?????????? ????? ???????? ???? ????????, ?? ???????? ???? ?? ????????? ?????????? GZipArchive.

1    using (GzipArchive archive = new GzipArchive())
2    {
3        archive.SetSource(dataDir + "data.bin");
4        archive.Save(dataDir + "archive.gz");
5    }

???????? ????? GZIP

? ?????????? ????? ???????? ???? ????????, ?? ???????? ????? GZip.

 1    //Extracts the archive and copies extracted content to file stream.
 2    using (var archive = new GzipArchive(dataDir + "archive.gz"))
 3    {
 4        using (var extracted = File.Create(dataDir + "data.bin"))
 5        {
 6            var unpacked = archive.Open();
 7            byte[] b = new byte[8192];
 8            int bytesRead;
 9            while (0 < (bytesRead = unpacked.Read(b, 0, b.Length)))
10                extracted.Write(b, 0, bytesRead);
11        }
12    }

??????? ? ????? ???�???

? ?????????? ????? ???????? ???? ????????, ?? ???????? ????? ?? ?????? ?? ??????????? ???? ? MemoryStream.

1    //Open an archive from a stream and extract it to a MemoryStream
2    var ms = new MemoryStream();
3    using (GzipArchive archive = new GzipArchive(File.OpenRead(dataDir + "sample.gz")))
4    {
5        archive.Open().CopyTo(ms);
6        Console.WriteLine(archive.Name);
7    }

???????? ? ?????

? ?????????? ????? ???????? ???? ????????, ?? ???????? ?? ???????? ? Stream.

1    //Writes compressed data to http response stream.
2    var ms = new MemoryStream();
3    using (var archive = new GzipArchive())
4    {
5        archive.SetSource(new FileInfo(dataDir + "data.bin"));
6        archive.Save(ms);
7    }

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.