Considering my product receiving lot of different filetypes and I cannot relay on the extension (sometimes it does not exist) to determine the filetype of the file.
Is there an API in aspose total that can tell the file type of the file?
sending the file one by one to all aspose products is not a good option
Thanks!
Currently, there is no single API in Aspose that can detect all file types. You will need to use different Aspose products to identify specific file types. For example, you can use Aspose.Words to check for Word documents, and for Excel files, you can refer to the documentation on detecting file formats and checking if a file is encrypted.
For file types that are not covered by these products, such as images or MSG files, you may need to implement your own logic based on the metadata or MIME type associated with those files.
If you are looking for a more streamlined approach, consider creating a wrapper function that utilizes the relevant Aspose APIs based on the initial checks you perform on the file. This way, you can minimize the number of calls to different APIs while still accurately determining the file type.
For more detailed guidance, you can refer to the following resources:
For Aspose.Cells, we already suggested the document(with example code) on how to detect a file format for your reference. This approach is already optimised and is fast. Aspose.Cells provides the FileFormatUtil.DetectFileFormat() static method and some relevant APIs that you can use to parse documents. My colleagues from Aspose.Words, Aspose.PDF and Aspose.Slides teams will assist you on detecting relevant file formats for your reference.
@yaird,
Unfortunately, Aspose.Total does not provide a single method to determine the type of files. As for PowerPoint documents, you can use Aspose.Slides for .NET like this:
var info = PresentationFactory.Instance.GetPresentationInfo(filePath);
Console.WriteLine("File format: " + info.LoadFormat);
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.