[
  {
    "Id": "484834",
    "ThreadId": "224833",
    "Html": "<p>I'm having problems zipping a file passed as a stream and moving that stream on its way.</p>\r\n<p>I'm writing the stream as an email attachment. The attachment is there, but the contents are unreadable.</p>\r\n<p>&nbsp;</p>\r\n<p>Here's my code:&nbsp;</p>\r\n<p>ms = New MemoryStream() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>ms.Write(attDoc, 0, attDoc.Length)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>ms.Seek(0, SeekOrigin.Begin) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>Dim ZipFile = New ZipFile()&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p>\r\n<p>ZipFile.AddEntry(&quot;etc.doc&quot;, ms)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>\r\n<p>ZipFile.Save(ms)</p>\r\n<p>email.Attachments.Add(&quot;attach.zip&quot;, ms)</p>\r\n<p>&nbsp;</p>\r\n<p>Any help would be appreciated.</p>\r\n<p>Thanks.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-08-25T13:21:05.587-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "484892",
    "ThreadId": "224833",
    "Html": "<p>Your code looks a little confused.&nbsp;</p>\r\n<p>From what I see, your code does this: 1. Write some data to a stream. &nbsp;2. Seek in that stream to the beginning. &nbsp;3. Open a zip file. 4. Add an entry to the zip file, specifying the stream from step 1. &nbsp;5. Save the zip file to the same stream. ???</p>\r\n<p>The problem is step 5. &nbsp;You are overwriting the source stream. &nbsp;If you want to create a memory stream that contains a zip file, then create a NEW memoryStream that receives the zip content. &nbsp;Any entries added to the zipfile should use unique streams.&nbsp;</p>\r\n<p>Good luck.&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-08-25T16:09:29.747-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "485678",
    "ThreadId": "224833",
    "Html": "<p>I completely missed the fact that I was overwriting the stream. Darn code blindness.</p>\r\n<p>I used a second stream, seek to 0 on that stream and everything is working.</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks!</p>",
    "PostedDate": "2010-08-27T06:33:40.747-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]