Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Stream fs = mySPFile.OpenBinaryStream();
- using (WordprocessingDocument ooxmlDoc = WordprocessingDocument.Open(fs, true))
- {
- MainDocumentPart mainPart = wordDoc.MainDocumentPart;
- XmlDocument xmlMainDocument = new XmlDocument();
- xmlMainDocument.Load(mainPart.GetStream());
- // change the contents of the ooxmlDoc / xmlMainDocument
- Stream stream = mainPart.GetStream(FileMode.Open, FileAccess.ReadWrite);
- xmlMainDocument.Save(stream);
- // the stream should not be longer than the DocumentPart
- stream.SetLength(stream.Position);
- }
- mySPFile.SaveBinary(fs);
- fs.Dispose();
Add Comment
Please, Sign In to add comment