if(txtFilePath.PostedFile.ContentType == "image/gif")
{
}
else
{
}

解决方案 »

  1.   

    string strExt = ".jpg";
    string strDefault = "";//要取的类型说明
    RegistryKey regRead;
    regRead = Registry.ClassesRoot.OpenSubKey(strExt, true);
    if(regRead != null)
    {

    strDefault = regRead.GetValue("Content Type").ToString();
    }
    regRead.Close();
      

  2.   

    如果你是文件上载时做判断的话,可以根据file.PostedFile.ContentType得到,但你要写成通过的话,只能自己把文件名和类型一个个对应了.
      

  3.   

    不要忘了读注册表要加上using Microsoft.Win32;
      

  4.   

    感谢快乐王子。对了 
      提示 asp.net用户没有该访问权限  但是 我已经设置asp.net用户为超级用户了。该怎么版?
      

  5.   

    可能的修改:
    machine.config运行domcnfg,默认安全机制,默认用户添加Everyone