Back to index

lightning-sunbird  0.9+nobinonly
MIMEService.cs
Go to the documentation of this file.
00001 
00002 namespace Silverstone.Manticore.Core
00003 {
00004   using System;
00005 
00006   using Microsoft.Win32;
00007 
00011        public class MIMEService
00012        {
00019     public static string GetExtensionForMIMEType(string aMIMEType)
00020     {
00021       RegistryKey clsRoot = Registry.ClassesRoot;
00022       string extFromMIMEDBKey = "MIME\\Database\\Content Type\\" + aMIMEType;
00023       RegistryKey extensionKey = clsRoot.OpenSubKey(extFromMIMEDBKey);
00024       return extensionKey.GetValue("Extension") as String;
00025     }
00026 
00035     public static string GetDescriptionForMIMEType(string aMIMEType)
00036     {
00037       RegistryKey clsRoot = Registry.ClassesRoot;
00038       string extension = GetExtensionForMIMEType(aMIMEType);
00039       RegistryKey handlerKey = clsRoot.OpenSubKey(extension);
00040       string handler = handlerKey.GetValue("") as String;
00041       RegistryKey descriptionKey = clsRoot.OpenSubKey(handler);
00042       string description = descriptionKey.GetValue("") as String;
00043       if (description == "")
00044         description = extension.Substring(1,extension.Length-1).ToUpper() + " file";
00045       return description;
00046     }
00047        }
00048 }