If a document has custom xml that contains a CDATA section, then loading the document will throw a FileCorruptedException. The following code can be used to duplicate the problem:
// using Aspose.Words for .NET v16.7.0.0
var doc = new Document();
doc.CustomXmlParts.Add(new CustomXmlPart { Id = Guid.NewGuid().ToString(), Data = Encoding.UTF8.GetBytes(@"") });
var fn = Path.Combine(Path.GetTempPath(), "cdata.xml");
doc.Save(fn, SaveFormat.FlatOpc);
// opening the document will throw the following exception:
//Aspose.Words.FileCorruptedException: The document appears to be corrupted and cannot be loaded. —>System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
//Parameter name: Unexpected XML event type: CDATA
// at .(XmlTextReader , StringBuilder , , )
// at .(XmlTextReader , )
// at .( )
// at .( )
// at .(Stream )
// at . ()
// at . ()
// at .()
// at .()
// at .(Stream , Encoding )
// at Aspose.Words.Document.(Stream , LoadOptions )
// — End of inner exception stack trace —
// at Aspose.Words.Document.(Stream , LoadOptions )
// at Aspose.Words.Document.(Stream , LoadOptions )
// at Aspose.Words.Document…ctor(String fileName, LoadOptions loadOptions)
// at Aspose.Words.Document…ctor(String fileName)
// at ConsoleApplication2.Program.Main(String []
// args) in C:\temp\ConsoleApplication2\Program.cs:line 25
var doc2 = new Document(fn);
Thank you