惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
腾讯CDC
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
量子位
F
Fortinet All Blogs
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
Tailwind CSS Blog
J
Java Code Geeks
S
SegmentFault 最新的问题
D
Docker
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
Jina AI
Jina AI
M
MIT News - Artificial intelligence
博客园 - 【当耐特】

博客园 - roboth

转:“由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值”的解决方法 .net tostring format格式说明 - roboth 一、DIP简介(DIP--Dependency Inversion Principle): 请确认 &lt;Import&gt; 声明中的路径正确,且磁盘上存在该文件。 异步委托 Visual Studio 最常用的13个快捷键 H1N1:速饮配方 [转]解决ASP.NET Web Applicatio超时时间已到.在操作完成之前超时时间已过或服务器未响应 - roboth 在线创建pdf msdn之sp_xml_preparedocument Route命令使用详解 电子书下载 买药记 抓取图片 xslt之<xsl:apply-templates - roboth - 博客园 盲人摸象 sql产生日历表 dom操作时机 js小技巧之访问元素属性
通过注册表获取文件的ContentType
roboth · 2009-07-02 · via 博客园 - roboth


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;namespace ObtainContenttype
{
    
class Program
    {
        
static void Main(string[] args)
        {
            GetFileContentType(
@"C:\Documents and Settings\roboth_staff\桌面\spx.txt");
        }
        
public static string GetFileContentType(string filename)
        {
            
string[] array = filename.Split('.');
            
string result = string.Empty;
            
string suffix = "." + array[array.Length - 1];
            RegistryKey rg 
= Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(suffix);
            
object obj = rg.GetValue("Content Type");
            result 
= obj != null ? obj.ToString() : string.Empty;
            rg.Close();
            
return result;
        }
    }
}

posted @ 2009-07-02 10:05  roboth  阅读(534)  评论()    收藏  举报