Problem writing directly from stream

Mar 12, 2011 at 7:54 AM

I'm trying to write a stream directly from memory to a zip, but all of my files come out as 0-byte files in the resulting zip.

 

                using (ZipFile package = new ZipFile(fullpath))
                using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter bin = new BinaryWriter(stream))
                {
                    bin.Write(version);
                    bin.Write(name);

...

                    if (package.ContainsEntry("index"))
                        package.UpdateEntry("index", stream);
                    else
                        package.AddEntry("index", stream);

                    package.Save();

                }

Anyone know what I'm doing wrong here?

 

Mar 12, 2011 at 11:18 PM

Nevermind, I figured it out. I just needed to rewind the stream before trying to save it.