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

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
Y
Y Combinator Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
S
SegmentFault 最新的问题
J
Java Code Geeks
V
Visual Studio Blog
H
Help Net Security
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
B
Blog RSS Feed
The Cloudflare Blog
MyScale Blog
MyScale Blog
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
美团技术团队

博客园 - 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)  评论()    收藏  举报