c# - Using .NET, how can you find the mime type of a file based on the file signature not the extension -


i looking simple way mime type file extension incorrect or not given, similar this question in .net.

in urlmon.dll, there's function called findmimefromdata.

from documentation

mime type detection, or "data sniffing," refers process of determining appropriate mime type binary data. final result depends on combination of server-supplied mime type headers, file extension, and/or data itself. usually, first 256 bytes of data significant.

so, read first (up to) 256 bytes file , pass findmimefromdata.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -