[
  {
    "Id": "240044",
    "ThreadId": "70466",
    "Html": "<p>I have a word 2007 file (docx) file in a memory stream..</p>\r\n<p>As the docx file is basically just a zip file with xml files contained within it, i'm trying to read it, but am getting the following error;</p>\r\n<p>&nbsp;</p>\r\n<p>\r\n<hr>\r\n</p>\r\n<p>\r\n<pre>Ionic.Zip.BadReadException occurred\r\n  Message=&quot;Could not read block - no data!  (position 0x0003953E)&quot;\r\n  Source=&quot;Ionic.Zip&quot;\r\n  StackTrace:\r\n       at Ionic.Zip.SharedUtilities._ReadFourBytes(Stream s, String message)\r\n       at Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf)\r\n       at Ionic.Zip.ZipFile.Read(Stream zipStream, TextWriter statusMessageWriter, Encoding encoding, EventHandler`1 readProgress)\r\n       at Ionic.Zip.ZipFile.Read(Stream zipStream, Encoding encoding)\r\n       at Attenda.URLContentReformat.DocxManipulator.UpdateDocXFile(String fileNameToReplace, String directoryPosition, Stream fileToUpdate) in C:\\Dev\\SourceRoot\\Service Review Documents\\Trunk\\src\\URLContentReformat\\DocxManipulator.vb:line 34\r\n  InnerException: <br><br><hr><br>Once i save the stream to the filesystem, i am able to read it in without issue.<br><br>This is the code i am using;<br><br><hr><div style=\"color:Black;background-color:White\"><pre>  <span style=\"color:Blue\">Private</span> <span style=\"color:Blue\">Sub</span> UpdateDocXFile(<span style=\"color:Blue\">ByVal</span> fileNameToReplace <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span>, <span style=\"color:Blue\">ByVal</span> directoryPosition <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span>, <span style=\"color:Blue\">ByVal</span> fileToUpdate <span style=\"color:Blue\">As</span> IO.Stream)\r\n    <span style=\"color:Blue\">Using</span> zip <span style=\"color:Blue\">As</span> ZipFile = ZipFile.Read(_worddocument, System.Text.Encoding.ASCII)\r\n      <span style=\"color:Green\">'Using zip As ZipFile = ZipFile.Read(&quot;C:\\myWord2007document.docx&quot;, System.Text.Encoding.ASCII)</span>\r\n      zip.UpdateEntry(fileNameToReplace, directoryPosition, fileToUpdate)\r\n      zip.Save(_worddocument)\r\n    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n  <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Sub</span>\r\n</pre>\r\n</div>\r\n<hr>\r\n<br>Obviously going wrong somewhere simple.... if someone can point me in the right direction it'd be appreciated.<br></pre>\r\n</p>",
    "PostedDate": "2009-09-29T08:44:56.343-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "240142",
    "ThreadId": "70466",
    "Html": "<p>The code you showed - it looks like the code that works.</p>\r\n<p>Can you show the code that does not work?</p>\r\n<p>How do you get the .docx content into the in-memory stream?&nbsp; Can you show that part, too?</p>\r\n<p>Is it possible that the content in the stream is not identical to the content of the file in the filesystem?</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-29T12:33:43.487-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]