Read the file we are going to compress into a FileStream
string filename = Server.MapPath("aatish.txt");
FileStream infile = File.OpenRead(filename);
byte[] buffer = new byte[infile.Length];
infile.Read(buffer, 0, buffer.Length);
infile.Close();
//Create the output file
FileStream outfile = File.Create(Path.ChangeExtension(filename,"zip"));
// Compress the input stream and write it to the output FileStream
GZipStream gzipStream = new GZipStream(outfile, CompressionMode.Compress);
gzipStream.Write(buffer, 0, buffer.Length);
gzipStream.Close();
Thursday, February 4, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment