Aspose.word.document can't load docx file

hi,

i have a word file
after.docx (799.1 KB)

when i used the below code to get the page count:

var aspDocument = new Aspose.Words.Document(tmpFileName);
aspDocument.Save(tmpFileName);
aspDocument = new Aspose.Words.Document(tmpFileName);
if (isUpdatePageLayout)
{
    aspDocument.UpdatePageLayout();
    aspDocument.UpdateTableLayout();
}
return aspDocument.PageCount;

an exception was thrown:

Aspose.Words.FileCorruptedException: ‘The document appears to be corrupted and cannot be loaded.’

InvalidOperationException: Cannot find part ‘’.

i double checked the document , can’t find any part reference id is empty.

can you please help me on this issue?

@vs6060_qq_com As I can see the attached document is actually corrupted even MS Word cannot open and recover it:

can you please help me find out where the problem in my docx file?

thank you very much.

@vs6060_qq_com The problem is in chart11.xml. There is

<c:userShapes r:id="rId1" />

but there is no corresponding .rels file with the specified relation. If remove this line the document can be loaded by MS Word and Aspose.Words.
in.docx (800.9 KB)

hi Alexey

thank you for your help,your suggestion works very well.

1 Like