The difference between the GZipStream and DeflateStream classes is the GZip header added by the GZipStream - you can open a file written to by the GZipStream using a GZip decompression utility (WinRAR if you're on Windows, GUnZip if you're on *nix).
FileStream fs = File.Open("testfile1.gz", FileMode.OpenOrCreate, FileAccess.Write);
GZipStream gz = new GZipStream(fs, CompressionMode.Compress);
string txt = "Famous last words";
byte[] byteArr = System.Text.ASCIIEncoding.ASCII.GetBytes(txt);
gz.Write(byteArr, 0, byteArr.Length);
gz.Flush();
gz.Close();
No comments:
Post a Comment