Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>FYKI, Check the registry under \HKEY_CLASSES_ROOT\MIME\Database\Content Type. There will be list of content type and file extension. If you could load this information through windows API then you can get your file extension to content type mapping. </p> <p>hth</p> <p>UPDATE : [source][1]</p> <pre><code>public string GetMIMEType(string filepath) { FileInfo fileInfo = new FileInfo(filepath); string fileExtension = fileInfo.Extension.ToLower(); // direct mapping which is fast and ensures these extensions are found switch (fileExtension) { case "htm": case "html": return "text/html"; case "js": return "text/javascript"; // registry may return "application/x-javascript" } // see if we can find extension info anywhere in the registry //Note : there is not a ContentType key under ALL the file types , check Run --&gt; regedit , then extensions !!! RegistryPermission regPerm = new RegistryPermission(RegistryPermissionAccess.Read, @"\\HKEY_CLASSES_ROOT"); // looks for extension with a content type RegistryKey rkContentTypes = Registry.ClassesRoot.OpenSubKey(fileExtension); if (rkContentTypes != null) { object key = rkContentTypes.GetValue("Content Type"); if (key != null) return key.ToString().ToLower(); } // looks for a content type with extension // Note : This would be problem if multiple extensions associate with one content type. RegistryKey typeKey = Registry.ClassesRoot.OpenSubKey(@"MIME\Database\Content Type"); foreach (string keyname in typeKey.GetSubKeyNames()) { RegistryKey curKey = typeKey.OpenSubKey(keyname); if (curKey != null) { object extension = curKey.GetValue("Extension"); if (extension != null) { if (extension.ToString().ToLower() == fileExtension) { return keyname; } } } } return null; } </code></pre> <p>[1]: <a href="http://www.codeproject.com/KB/dotnet/ContentType.aspx?msg=2903389#xx2903389xx" rel="nofollow noreferrer">http://www.codeproject.com/KB/dotnet/ContentType.aspx?msg=2903389#xx2903389xx</a><code>enter code here</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload