FileFormat.Detect

Detect(Stream, string)

从数据流检测文件格式,文件名是可选的,用于猜测没有魔术头的类型。

public static FileFormat Detect(Stream stream, string fileName)
参数类型描述
streamStream用于检测的数据流
fileName字符串数据的原始文件名,用作提示。

返回值

检测到的类型的 FileFormat 实例,如果失败则为 null。

异常

异常条件
IOException读取数据失败时抛出的异常。

示例

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}");

另请参见


Detect(string)

从文件名检测文件格式,文件必须可读取,以便 Aspose.3D 能通过文件头检测文件格式。

public static FileFormat Detect(string fileName)
参数类型描述
fileName字符串用于检测文件格式的文件路径。

返回值

检测到的类型的 FileFormat 实例,如果失败则为 null。

异常

异常条件
IOException读取数据失败时抛出的异常。

示例

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

另请参见