This project has moved and is read-only. For the latest updates, please go here.

Textfile filestream to ZipStorer

Mar 11, 2012 at 5:44 AM

Hi I am trying to convert a method from writing a regular textfile to doing it in a zip file

Here's what I've tried:

void savepfc(string file)


MemoryStream fsOutput = new MemoryStream();

           // FileStream fsOutput = new FileStream(file, FileMode.Create, FileAccess.Write);           

StreamWriter srOutput = new StreamWriter(fsOutput);           



*snips about 20 srOutput.WriteLines...

ZipStorer zipfile = ZipStorer.Create(file, "This is a product file");           

zipfile.AddStream(ZipStorer.Compression.Deflate, "product.txt", fsOutput, DateTime.Now, "This is your product."); 




But when I check the txt file inside the zip its got nothing in it.

I've not used memorystreams before. Are they different from filestreams?

Mar 11, 2012 at 6:47 AM

Got this figured out

I put the following in after srOutput.Flush(); and it works

            fsOutput.Seek(0, SeekOrigin.Begin);