使用静态类MimeMapping(需要.NET Framework 4.5及以后的支持)
string fileName = "D:myfile.txt"; var contentType = System.Web.MimeMapping.GetMimeMapping(fileName);
如果没有对应的MIME TYPE,将会返回:
application/octet-stream
string fileName = "D:myfile.txt"; var contentType = System.Web.MimeMapping.GetMimeMapping(fileName);
如果没有对应的MIME TYPE,将会返回:
application/octet-stream