I am trying to create a docx file that I can open in open office writer with the following code. The app runs and creates the doc, but when I try to open it I get a "general input/output error" message. If I try to open in word it works fine. Every example I've seen shows to do it this way.
using (var doc = WordprocessingDocument.Create("C:\\tmp\\test123.docx", WordprocessingDocumentType.Document, true))
{
var mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document();
var docBody = mainPart.Document.AppendChild(new Body());
for (var i = 0; i <= 7; i++)
docBody.Append(new Paragraph(new Run(new Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sodales orci quis molestie ornare. Nullam id dictum purus."))));
doc.MainDocumentPart.Document.Save();
doc.Close();
}
I created a test docx file in ms word and then renamed it and the file created with the code above to zip files. When looking at the contents of the zip file it looks like the code above is not creating a number of files. I don't know if they're needed or not, but wondered if that could be the cause. In the image below, the one on the right is the one that I created in word and it opens fine.