【发布时间】:2015-02-23 08:40:54
【问题描述】:
我已使用代码here 来获取文件的 MIME 类型。
作为
public static string GetContentType(string fileName)
{
var extension = Path.GetExtension(fileName);
if (String.IsNullOrWhiteSpace(extension))
{
return null;
}
var registryKey = Registry.ClassesRoot.OpenSubKey(extension);
if (registryKey == null)
{
return null;
}
var value = registryKey.GetValue("Content Type") as string;
return String.IsNullOrWhiteSpace(value) ? null : value;
}
但它总是为 sql 文件返回 null。任何想法我做错了什么。
【问题讨论】:
标签: c# mime-types