Method GetFileFormat
GetFileFormat(string)
Gets the file format.
public static FileFormat GetFileFormat(string filePath)
Parameters
filePath
stringThe file path.
Returns
- FileFormat
The determined file format.
Examples
Determines whether file is a DWG drawing
var fileFormat = Image.GetFileFormat("file.dwg");
if (fileFormat >= FileFormat.CadR010 && fileFormat <= FileFormat.CadR2010)
{
Console.WriteLine("This is a DWG drawing");
}
Remarks
The file format determined does not mean that the specified image may be loaded. Use one of the CanLoad method overloads to determine whether file may be loaded.
GetFileFormat(Stream)
Gets the file format.
public static FileFormat GetFileFormat(Stream stream)
Parameters
stream
StreamThe stream.
Returns
- FileFormat
The determined file format.
Examples
Determines whether a stream contains a DXF drawing
using (var f = File.OpenRead("file.dxf"))
{
var fileFormat = Image.GetFileFormat(f);
if (fileFormat >= FileFormat.DXFCadR010 && fileFormat <= FileFormat.DXFCadR2010)
{
Console.WriteLine("This is a DXF drawing");
}
}
Remarks
The file format determined does not mean that the specified image may be loaded. Use one of the CanLoad method overloads to determine whether stream may be loaded.