Многие из них доступны по всему Интернету: у меня тоже был мой, пока я не нашел этого замечательного проекта GitHub , который охватывает гигантское их количество: он также включает в себя эффективный и детерминированныйспособ отображения, так что вы также можете использовать его наоборот (получить расширение от данного типа MIME).
Я думаю, этот файл поможет вам:
MimeTypeMap
using System;
using System.Collections.Generic;
using System.Linq;
namespace MimeTypes
{
public static class MimeTypeMap
{
private static readonly Lazy<IDictionary<string, string>> _mappings = new Lazy<IDictionary<string, string>>(BuildMappings);
private static IDictionary<string, string> BuildMappings()
{
var mappings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {
#region Big freaking list of mime types
{".323", "text/h323"},
{".3g2", "video/3gpp2"},
{".3gp", "video/3gpp"},
{".3gp2", "video/3gpp2"},
{".3gpp", "video/3gpp"},
.
.
.
.
{"video/x-dv", ".dv"},
{"video/x-la-asf", ".lsf"},
{"video/x-ms-asf", ".asf"},
{"x-world/x-vrml", ".xof"},
#endregion
};
var cache = mappings.ToList(); // need ToList() to avoid modifying while still enumerating
foreach (var mapping in cache)
{
if (!mappings.ContainsKey(mapping.Value))
{
mappings.Add(mapping.Value, mapping.Key);
}
}
return mappings;
}
public static string GetMimeType(string extension)
{
if (extension == null)
{
throw new ArgumentNullException("extension");
}
if (!extension.StartsWith("."))
{
extension = "." + extension;
}
string mime;
return _mappings.Value.TryGetValue(extension, out mime) ? mime : "application/octet-stream";
}
public static string GetExtension(string mimeType)
{
return GetExtension(mimeType, true);
}
public static string GetExtension(string mimeType, bool throwErrorIfNotFound)
{
if (mimeType == null)
{
throw new ArgumentNullException("mimeType");
}
if (mimeType.StartsWith("."))
{
throw new ArgumentException("Requested mime type is not valid: " + mimeType);
}
string extension;
if (_mappings.Value.TryGetValue(mimeType, out extension))
{
return extension;
}
if (throwErrorIfNotFound)
{
throw new ArgumentException("Requested mime type is not registered: " + mimeType);
}
else
{
return string.Empty;
}
}
}
}