I am using C# and Microsoft.Office.Interop.Word to work with Microsoft word document. The trouble is when I rename an image to the file extension .doc and then call the com object as follows it hangs. There must be a way to test if the file is a valid word document before attempting to open it. Anyone have an answer?
ApplicationClass.Documents.Open(ref path,
ref missing, ref readOnly,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible,
ref missing, ref missing, ref missing);
After some testing I decided to use Aspose: http://www.aspose.com/
It turns out this is very powerful and simple to use. It throws an exception when a document is not in the correct format which can be caught and handled.