More mime types

This commit is contained in:
Jaex 2014-04-16 16:17:03 +03:00
parent 2c161a3e26
commit 3865dede56
2 changed files with 1020 additions and 575 deletions

View file

@ -255,14 +255,28 @@ public static string GetMimeType(string fileName)
if (!string.IsNullOrEmpty(fileName))
{
string ext = Path.GetExtension(fileName).ToLower();
RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(ext);
if (regKey != null && regKey.GetValue("Content Type") != null)
if (!string.IsNullOrEmpty(ext))
{
return regKey.GetValue("Content Type").ToString();
}
else
{
return MimeTypes.GetMimeType(ext);
string mimeType = MimeTypes.GetMimeType(ext);
if (!string.IsNullOrEmpty(mimeType))
{
return mimeType;
}
using (RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(ext))
{
if (regKey != null && regKey.GetValue("Content Type") != null)
{
mimeType = regKey.GetValue("Content Type").ToString();
if (!string.IsNullOrEmpty(mimeType))
{
return mimeType;
}
}
}
}
}

File diff suppressed because it is too large Load diff