获取文件的ContentType

1 public static string GetFileContentType(string filename)
2 {
3 string[] array = filename.Split('.');
4 string result = string.Empty;
5 string suffix = "." + array[array.Length - 1];
6 RegistryKey rg = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(suffix);
7 object obj = rg.GetValue("Content Type");
8 result = obj != null ? obj.ToString() : string.Empty;
9 rg.Close();
10 return result;
11 }

 

posted on 2010-12-07 08:59  沃叶徐  阅读(1542)  评论(0)    收藏  举报

导航