Free Support Forum - aspose.com

File type verification


#1

Hi, I am wondering if something in the Aspose product family would allow verification of file content – eg. is there something that can be used to check if a file with a docx extension is actually a docx? If so, is there something available for a .doc and a pdf?
Thank you!


#2

@AlinaS,

In case of Word documents such as DOCX, DOC, RTF, ODT etc, the following page shows how to use the FileFormatUtil.DetectFileFormat methods of Aspose.Words for .NET API to detect the file format:
FileFormatUtil.DetectFileFormat Method (String)

You can also use Aspose.PDF for .NET API to verify if a PDF file is actually a PDF file or not with IsPdfFile property.

PdfFileInfo info = new PdfFileInfo(fileName);
bool flag = info.IsPdfFile;

See PdfFileInfo Class