using System.DirectoryServices;
public static string GetMimeType(string extension)
{
string retMimeType = null;
using (DirectoryEntry mimeMap = new DirectoryEntry("IIS://Localhost/MimeMap"))
{
PropertyValueCollection pValues = mimeMap.Properties["MimeMap"];
foreach (object value in pValues)
{
IISOle.IISMimeType mimeType = (IISOle.IISMimeType)value;
if (extension == mimeType.Extension)
{
retMimeType = mimeType.MimeType;
}
}
}
return retMimeType;
}
Saturday, June 6, 2009
Get Mime Type from IIS
Except the System.DirectoryServices, I also need to add a reference of com object "Active DS IIS Namespace Provider" in VS.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment