Free Support Forum -

Validation Tool


I think I read someplace that there was a tool one could use to validate files before trying to open and manipulate them. I can't find where I read that. Can someone point me in the right direction?

I'm extracting text from many different file types and while I have my own way to narrow down the file type, I would like to use the Aspose validation tool on files before trying to open them in the API.



Aspose.Cells provides a utility class “CellsHelper” which has some useful static methods. I think you may use CellsHelper.DetectFileFormat static method to know about the file formatting type before loading/opening it by Aspose.Cells.


Sample code:

string filePath = “FILE_NAME_with_respect_to_PATH/Location”;
//You may also get the file into streams for DetectFileFormat overloads.
FileFormatType fmt = CellsHelper.DetectFileFormat(filePath);
Debug.WriteLine("Input File Format: " + fmt);

Let us know if you have other issues or still have any confusion.

Thank you.


Thanks for using Aspose.Cells for .NET.

Please also check the following document article for more help. It explains how to use CellsHelper.DetectFileFormat or CellsHelper.DetectLoadFormat static methods before actually opening your file. These methods are necessary in scenarios when you want to validate your file based on contents because sometimes file extensions are wrong or missing totally.