public class Gzip {
public static void Compress(Stream inputStream, Stream outputStream) {
using (var gzip = new GZipStream(outputStream, CompressionMode.Compress)) {
byte[] buffer = new byte[8192];
int count;
while ((count = inputStream.Read(buffer, 0, buffer.Length)) > 0) {
gzip.Write(buffer, 0, count);
}
}
}
public static void Decompress(Stream inputStream, Stream outputStream) {
using (var gzip = new GZipStream(inputStream, CompressionMode.Decompress)) {
byte[] buffer = new byte[8192];
int count;
while ((count = gzip.Read(buffer, 0, buffer.Length)) > 0) {
outputStream.Write(buffer, 0, count);
}
}
}
}
Comments
Post a Comment