[
  {
    "Id": "435876",
    "ThreadId": "210673",
    "Html": "<p>Hi guys, thanks for great software. I am having some problems, though (I am not the most experienced programmer...)</p>\r\n<p>I wonder if it is possible to handle ZipFile objects in memory, without saving to disk? I have seen some examples using memoryStream, but they do not work the way I want them to work ;)</p>\r\n<p>Example:</p>\r\n<p>&nbsp;</p>\r\n<div style=\"color:black;background-color:white\">\r\n<pre><span style=\"color:blue\">public</span> ZipFile GenerateZipFile(SomeObject o)\r\n       {\r\n          <span style=\"color:blue\">using</span> (<span style=\"color:blue\">var</span> zip = <span style=\"color:blue\">new</span> ZipFile())\r\n         {\r\n         <span style=\"color:green\">// Some code that adds files to the zipFile</span>\r\n          }\r\n       <span style=\"color:blue\">return</span> zip;\r\n       }\r\n</pre>\r\n</div>\r\n<p>&nbsp;</p>\r\n<p>And the other way:</p>\r\n<p>&nbsp;</p>\r\n<div style=\"color:black;background-color:white\">\r\n<pre><span style=\"color:blue\">public</span> SomeObject GetObjectsFromZipFile(ZipFile zip)\r\n       {\r\n         <span style=\"color:blue\">var</span> o = <span style=\"color:blue\">new</span> SomeObject();\r\n         <span style=\"color:green\">// Some code that extracts the file from the zip file into o</span>\r\n       <span style=\"color:blue\">return</span> o;\r\n       }\r\n<br>For the GenerateZipFile method, I have tried using a stream, but an empty document is added to the zip file:<br><br><div style=\"color:black;background-color:white\"><pre>      <span style=\"color:blue\">public</span> ZipFile GenerateZipFile(SomeXmlObject o)\r\n      {\r\n         <span style=\"color:blue\">using</span> (<span style=\"color:blue\">var</span> zipFile = <span style=\"color:blue\">new</span> ZipFile())\r\n         {\r\n            <span style=\"color:blue\">var</span> serialiser = <span style=\"color:blue\">new</span> Serialiser();\r\n            MemoryStream xmlStream = serialiser.Serialise(o);\r\n            zipFile.AddEntry(<span style=\"color:#a31515\">&quot;SomeXmlObject.xml&quot;</span>, xmlStream);\r\n\r\n            <span style=\"color:blue\">return</span> zipFile;\r\n         }\r\n</pre>\r\n</div>\r\n<pre>I can see while debugging that the xmlStream has data, but the file inside the resulting zip file is 0 bytes...<br><br>I tried doing zip.Save(); before returning, but it will not let me save without having a filename or a stream. But I have an object, shouldn't that be enough?</pre>\r\n</pre>\r\n</div>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-04-27T03:43:19.38-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "435879",
    "ThreadId": "210673",
    "Html": "<p>Ok, the last code snippet is now fixed - I had forgotten to reset the cursor before returning the stream from the serialiser...</p>\r\n<p>&nbsp;</p>\r\n<p>But I still wonder about the other things =)</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-04-27T03:56:10.987-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "436266",
    "ThreadId": "210673",
    "Html": "<p>I'm not clear on the question here.</p>\r\n<p>Maybe you can rephrase it for me.</p>",
    "PostedDate": "2010-04-27T19:25:15.553-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "436332",
    "ThreadId": "210673",
    "Html": "<p>Hi Cheeso, I'm not really sure what I'm asking anymore actually. I have some working code right now, so I'll work some more on that and see if I run into more problems.</p>\r\n<p>I think I was generally frustrated because of streams, which was all new to me. So never mind me ;)</p>",
    "PostedDate": "2010-04-27T23:33:31.417-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "436591",
    "ThreadId": "210673",
    "Html": "<p>ha!&nbsp; ok, well, good luck!</p>",
    "PostedDate": "2010-04-28T08:56:02.36-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]