在我使用C#构建的Windows服务中,我尝试根据文件扩展名设置mime类型,如下所示
static string GetMimeType(string fileName)
{
string mimeType = "application/unknown";
string ext = Path.GetExtension(fileName).ToLower();
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
if (regKey != null && regKey.GetValue("Content Type") != null)
mimeType = regKey.GetValue("Content Type").ToString();
return mimeType;
}
Run Code Online (Sandbox Code Playgroud)
在生产服务器上,由于显而易见的原因,我们没有安装Acrobat或word.我该如何解决这个问题?还有其他设置mime类型的方法吗?如果不是如何在生产服务器上创建这些mime类型而不必安装这些软件.
提前致谢