I was searching for a way to get the MIME type of a file by file extension and .NET Framework 4.5 comes to the rescue.
You can make use of API GetMimeMapping which is found in the .NET Framework 4.5 System.Web.dll
Here is the documentation of it: MimeMapping.GetMimeMapping Method.
Example on how you can use it:
- string mimeType = System.Web.MimeMapping.GetMimeMapping(fileName);
Hope you find this useful.
Reference: Getting a MIME type from a file extension in ASP.NET 4.5.

Join the conversation! Your thoughts help the community grow.