从文件扩展名获取MIME类型

本文翻译自:Get MIME type from filename extension

如何从文件扩展名中获取MIME类型?


#1楼

参考:https://stackoom.com/question/4Jsi/从文件扩展名获取MIME类型


#2楼

You can find that information in the registry. 您可以在注册表中找到该信息。 For instance, the MIME type for .pdf file can be found in the key HKEY_CLASSES_ROOT\\.pdf , in the value "Content Type" : 例如,.pdf文件的MIME类型可以在密钥HKEY_CLASSES_ROOT\\.pdf中找到,值为“内容类型”:

string mimeType = Registry.GetValue(@"HKEY_CLASSES_ROOT\.pdf", "Content Type", null) as string;

#3楼

You could use the table provided from Apache 's httpd. 你可以使用Apache的httpd提供的表。 It should be trivial to map this into a function, dictionary, list, etc. 将它映射到函数,字典,列表等应该是微不足道的。

Also, as seen here , extension->mime type is not necessarily a function. 此外,由于看到

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值