Friday, December 3, 2010

Can You Get Soulsilver For Vba

Dynamically creating a ZIP file. Net C #

I wanted to present a code that generates a zip file in memory and then send it by Customer Request.

code is a fairly simple but can get us out of trouble.

NPOI
Use the library, which can be downloaded from: http://dotnetzip.codeplex.com/


private void
 
responseZipFile (Object data, object sender, EventArgs e)

{using (StringWriter sw = new StringWriter ()) {

using (MemoryStream ms = new MemoryStream ()) {

Response.Clear ();
Response.Buffer = true;
Response.ContentType = "aplication/zip";
Response.AddHeader("Content-Disposition", "attachment;filename=file.zip");
this.EnableViewState = false;

using (ZipFile zip = new ZipFile())
{
zip.AddEntry("Readme.txt", "stringContent1");
zip.AddEntry("readings/Data.csv", "stringContent2");
zip.AddEntry("readings/Index.xml", "stringContent3");
zip.Save(ms);
}

HttpContext.Current.Response.BinaryWrite(ms.ToArray());
HttpContext.Current.Response.End();
}
}}

I hope will be useful. Greetings

0 comments:

Post a Comment