.NetFramework 中获取 MimeType

1
2
// using System.Web;
MimeMapping.GetMimeMapping(filename);

.NetCore 中获取MimeType

1
2
3
4
//using Microsoft.AspNetCore.StaticFiles;
FileExtensionContentTypeProvider fileExtensionContentTypeProvider;
string contentType;
fileExtensionContentTypeProvider.TryGetContentType(filename,out contentType);