Hi there,
We are currently trying to outline a strategy for detecting the Aspose component (starting from Detect file types from stream - #7 by codewarior) that could handle a stream based on utilities function like:
var fileFormatInfo = Aspose.Cells.FileFormatUtil.DetectFileFormat(input);
if (fileFormatInfo.LoadFormat != Aspose.Cells.LoadFormat.Unknown)
{
canHandle = true;
}
The one we use for Aspose.CAD 19.9.0 is:
var canHandle = false;
try
{
input.Position = 0L;
var fileFormatInfo = Aspose.Diagram.FileFormatUtil.DetectFileFormat(input);
if (fileFormatInfo.FileFormatType != Aspose.Diagram.FileFormatType.Unknown
&& fileFormatInfo.FileFormatType != Aspose.Diagram.FileFormatType.Pdf)
{
canHandle = true;
}
}
catch (Exception)
{
}
This is not ideal as:
- there is no LoadFormat property in the fileFormatInfo object as Aspose.Words.FileFormatUtil.DetectFileFormat(input) has
- this means that we could rely on FileFormatType data only but that enum is basically all the file formats that Aspose handles through all of their components.
Is there a better way to do it?
Thank you!