Free Support Forum -

"new Document(filename)" throw a Exeception when pass in a 0byte docx file

In win7 64bit, I create a new docx file which is 0bytes, my code "var file = new Document(filename);" will throw "unknown file format" Exeception when I pass in this file.

I also met this problem. Please give us feedback quickly


Thanks for your inquiry. This is not a bug in Aspose.Words. In this case, the file with zero length has no header. All object files have the header by which one can understand that the format and version of the format.

You can check the file size before loading it into Aspose.Words.Document by using following code snippet.

FileInfo f = new FileInfo(MyDir + "in.docx");

long size = f.Length;

Hope this answers your query. Please let us know if you have any more queries.

Thanks for your reply.

Hi there,

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.