private static IDictionary _mappings = new Dictionary(StringComparer. I've compiled a list from these locations and added a few others that we use.ĮDIT: See most up-do-date version with contributions here, including an efficient and deterministic two-way mapping.
File extension lookup windows#
I've found many mime types my application uses are not in the default Windows registry and others are in the registry but not in the list included with IIS. MimeMapping._mappingDictionary.AddMapping(string fileExtension, string mimeType)įor up-to-date mapping with additions from many contributors, see this GitHub repository: work).Īnyway, when using reflection to add MIME types, be aware that since you're accessing a private field, its name might change or even be totally removed, so you should be extra cautious and add double checks and provide fail safe action for every step. If you need to add custom mappings you probably can use reflection to add mappings to the BCL MimeMapping class, it uses a custom dictionary that exposes this method, so you should invoke the following to add mappings (never tested tho, but should prob.
File extension lookup how to#
In this lesson, well go over some examples of these extensions, as well as how to determine a particular files extension. These extensions tell you about the characteristics of a file and its use. NET Framework 4.5: string mimeType = MimeMapping.GetMimeMapping(fileName) A file extension is a three- or four-letter identifier found at the end of a file name and following a period. Use the method, that is part of the BCL in.