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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

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

unit testing - How to mock PreferenceManager in Android? -