FileFormat.Detect

Detect(Stream, string)

Detect the file format from data stream, file name is optional for guessing types that has no magic header.

public static FileFormat Detect(Stream stream, string fileName)
ParameterTypeDescription
streamStreamStream containing data to detect
fileNameStringOriginal file name of the data, used as hint.

Return Value

The FileFormat instance of the detected type or null if failed.

Exceptions

exceptioncondition
IOExceptionException thrown when failed to read data.

Examples

byte[] bytes = new byte[100];//take the bytes from your source
var fmt = FileFormat.Detect(new MemoryStream(bytes), "input-file");
Console.WriteLine($"Input data format: {fmt}");

See Also


Detect(string)

Detect the file format from file name, file must be readable so Aspose.3D can detect the file format through file header.

public static FileFormat Detect(string fileName)
ParameterTypeDescription
fileNameStringPath to the file to detect file format.

Return Value

The FileFormat instance of the detected type or null if failed.

Exceptions

exceptioncondition
IOExceptionException thrown when failed to read data.

Examples

var fmt = FileFormat.Detect("input.fbx");
Console.WriteLine($"Input file format: {fmt}");

See Also