Get MIME Type

Manipulating the application behavior based on the file type is a common scenario (like checking if used uploaded a PDF file or text file; whether video is custom player compatible or not, etc.). The whole process here depends on the MIME type that can be captured from the file extension and accuracy of getting MIME type is a key here.

Two approaches that you can look for in order to get the MIME type from File extension:

Approach#1 : Reading MIME type with the help of Windows registry. This approach depends on the fact the file type you are interested with must be registered in the machine where code is running.

Approach#2: Maintain an exhaustive list of MIME types as Dictionary to get the appropriate as per your requirement.  You can customize this list and is machine independent.

Cheers!!