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

Manual zip-creation issue using ZipStorer

Mar 28, 2013 at 7:55 AM
This code works fine
 ZipStorer storer = ZipStorer.Create(@"H:\temp\sysInfo.zip", "");
    if (systemInfoStream != null)
       storer.AddStream(ZipStorer.Compression.Deflate, "SystemInfo.txt", 
                        systemInfoStream, DateTime.Now, null);  
But when I try to use inner stream of ZipStorer manually is does not work fine:
    MemoryStream result = new MemoryStream();
    ZipStorer storer =ZipStorer.Create(new MemoryStream(), "");
    if (systemInfoStream != null) {
        storer.AddStream(ZipStorer.Compression.Deflate, "SystemInfo.txt", 
                         systemInfoStream, DateTime.Now, null);
        storer.ZipFileStream.Position = 0;
        storer.ZipFileStream.CopyTo(result);
    }
    File.WriteAllBytes(@"H:\temp\sysInfo.zip", result.ToArray());
The result of the second sample is the damaged zip-file which can be read after repairing with WinRar.
The first sample works just fine. The only significant difference that I see is that in the second sample I dont add file to the storer explicitly.