I have a word 2007 file (docx) file in a memory stream..
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;
Message="Could not read block - no data! (position 0x0003953E)"
at Ionic.Zip.SharedUtilities._ReadFourBytes(Stream s, String message)
at Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf)
at Ionic.Zip.ZipFile.Read(Stream zipStream, TextWriter statusMessageWriter, Encoding encoding, EventHandler`1 readProgress)
at Ionic.Zip.ZipFile.Read(Stream zipStream, Encoding encoding)
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
Once i save the stream to the filesystem, i am able to read it in without issue.
This is the code i am using;
Private Sub UpdateDocXFile(ByVal fileNameToReplace As String, ByVal directoryPosition As String, ByVal fileToUpdate As IO.Stream)
Using zip As ZipFile = ZipFile.Read(_worddocument, System.Text.Encoding.ASCII)
'Using zip As ZipFile = ZipFile.Read("C:\myWord2007document.docx", System.Text.Encoding.ASCII)
zip.UpdateEntry(fileNameToReplace, directoryPosition, fileToUpdate)
Obviously going wrong somewhere simple.... if someone can point me in the right direction it'd be appreciated.
Sep 29, 2009 at 8:33 PM
The code you showed - it looks like the code that works.
Can you show the code that does not work?
How do you get the .docx content into the in-memory stream? Can you show that part, too?
Is it possible that the content in the stream is not identical to the content of the file in the filesystem?