Detecting if Aspose.CAD can handle a stream

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:

  1. there is no LoadFormat property in the fileFormatInfo object as Aspose.Words.FileFormatUtil.DetectFileFormat(input) has
  2. 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!

@gwert,

I have observed your requirements and an issue with ID CADNET-1054 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.