As you know files have extensions and mime types.
but these two attributes are not intelligent enough two determine exact type of file. For example I have a .exe
file and i rename it's extension two .png
. So if I try to find out it's type or mime type programmatically the result will be images/png
or .png
but I want to read the header of file and find out exact file type. Is it possible programmatically with C# language?
Edit
Of course some questions are similar to mine but as you know files starts with a hex string, for example :
"JPEG", ".jpg", 0xFF, /*0xD*/ 0xD8, 0xFF, 0xE0, null, null, 0x4A, 0x46, 0x49, 0x46, 0x00
"Graphics Interchange Format 87a", ".gif", 0x47, 0x49, 0x46, 0x38, 0x37, 0x6
and etc.
Do file types have similar starting hex format?