We are currently on Aspose.Word v6.4 and are currently evaluating on upgrading to v8 for the Wordart supports. It looks like that v8 does not support a document to open/save with .temp extensions. After changing .temp to .doc, it’s fine. But with .temp, an exception will occur like this:
for a save:
FATAL Unhandled Thread Exception Exception
System.ArgumentException: Invalid file format requested.
at Aspose.Words.Document.?(SaveFormat ?)
at Aspose.Words.Document.?(Stream ?, String ?, SaveFormat ?)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
at Aspose.Words.Document.Save(String fileName)
for a open:
FATAL Unhandled Thread Exception Exception
Aspose.Words.UnsupportedFileFormatException: Unknown file format.
at Aspose.Words.Document.?(Stream ?, LoadFormat ?, String ?)
at Aspose.Words.Document.?(Stream ?, LoadFormat ?, String ?)
at Aspose.Words.Document... ctor(String fileName, LoadFormat loadFormat, String password)
at Aspose.Words.Document... ctor(String fileName)
I didn’t test with other extensions though, just thougt this will be an issue if it’s only working with a particular extension like .doc?
Thanks for your request. I cannot reproduce the problem on my side. I used the following code for testing:
Document doc = new Document(@“Test001\in.temp”); // in.temp is DOC file, i just changed an extension.
doc.Save(@"Test001\out.temp", SaveFormat.Doc);
Could you please attach your document and code? I will check it and provide you more information.
Best regards.
Thank you for additional information. An extension of the file is used to determine the destination file format. If you need to use some custom extension, like .temp, you should specify the destination file format explicitly, as was shown in my previous answer. I think, this is correct, because you should know what the expected output file format is.
By the way, there should not be any problems with opening documents with custom extension.
Best regards.
No, I don’t think this is correct. Also this used to work in v6.4, there must be something changed in v8.
A temp file was just used temporarily for storage and buffering. It will be awkward if you have to rename the extension to be something like .doc, .docx etc. A name is just a name and technically you should be able to use any extension and add association to a program like MS Word if you want to.
Like in my sample code, I don’t think it’s right if you have to modify the extesion to mak eit acceptable by Aspose.Document.Save functions.
Thank you for additional information. Actually, I did not suggest you to change extension of your files to DOC. I just advised you to specify SaveFormat explicitly, if you need to use custom extension, like shown below: