Extracting from Memory stream to byte array (with in Memory stream)

Aug 27, 2012 at 2:07 PM
Edited Aug 27, 2012 at 2:09 PM

Hi All,

This is first time i am using this utility. Very frankly haven't done much RND on this. My requirment is straigh forward but my code is not working due to some reason. The requirement is as follows:

1.  I will get a ZIP file stream with no of PDF files in it.

2.  I need to extract this zip file and convert it into a list of byte array of individual PDF's.

3. All this should be done in-memory only.

for your reference I have added a dummy code behind code with 2 button one to zip and data and another to unzip it.

*********

using System;

 

using System.Collections.Generic;

 

using System.Linq;

 

using System.Web;

using System.Web.UI;

 using System.Web.UI.WebControls;

 

using Ionic.Zip;

using System.IO;

namespace ZipRND

{



public partial class _Default: System.Web.UI.Page

 {

 

MemoryStream myInPutStream = new MemoryStream ();

 

MemoryStream myOutPutStream = new MemoryStream ();   

 

protected void btnCreate_Click(object sender, EventArgs e)  

 

 

protected void btnExtract_Click(object sender, EventArgs e) using (ZipFile zip1 = ZipFile.Read(myInPutStream))    foreach (ZipEntry eZip in zip1)      }

 

*********

 

Thanks a lot. 

}

}

}

 

{

using (ZipFile zip = new ZipFile())

zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G"

);  

 

zip.Save(myInPutStream);

}

 

 

 

{

zip.AddDirectory(@"C:\My Files", "MyFilesAre"

);