Method DetectMimeType
DetectMimeType(string)
Detects the MIME type of the file at the specified path, using only the formats supported by the toolkit.
public static string DetectMimeType(string path)
Parameters
path
stringThe file system path to inspect.
Returns
- string
A MIME type string for supported formats (e.g.,
image/png
,text/html
,application/pdf
), or an empty string if the format is not recognized.
Exceptions
- FileNotFoundException
Thrown if the file does not exist.
- IOException
Thrown if an I/O error occurs while reading the file.
DetectMimeType(byte[], string)
Detects the MIME type of the provided byte array, using only the formats supported by the toolkit.
public static string DetectMimeType(byte[] data, string fileName = "")
Parameters
data
byte[]The file data to inspect.
fileName
stringOptional file name that may help with format-specific detection. Default: empty string.
Returns
- string
A MIME type string for supported formats, or an empty string if the content is not recognized.