using System.IO.Compression;
public static void ExportAsGZip(Stream stream, string fileName)
{
HttpContext.Current.Response.ContentType = "application/gzip";
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.gz", fileName));
using (GZipStream compressionStream = new GZipStream(HttpContext.Current.Response.OutputStream, CompressionMode.Compress))
{
stream.CopyTo(compressionStream);
}
}
{
HttpContext.Current.Response.ContentType = "application/gzip";
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.gz", fileName));
using (GZipStream compressionStream = new GZipStream(HttpContext.Current.Response.OutputStream, CompressionMode.Compress))
{
stream.CopyTo(compressionStream);
}
}
Comments
Post a Comment