使用System.IO下的Path类:
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemiopathclasstopic.aspPath.GetExtension() 方法分析您传递给它的字符串,并且从该字符串返回扩展名

解决方案 »

  1.   

    string name=Path.GetExtension("f:\123\12345.rm");
      

  2.   

    string.LastIndexOf('.')//得到最后一个.符的索引。接下来几个索引的字符就是扩展名了
      

  3.   

    string FileName=文件名;//包括路径也没有问题
    int pos = FileName.LastIndexOf(".");
    string FileType = FileName.Substring(pos);
      

  4.   

    如果文件没有扩展名,比如
    c:\my.test\file
    楼上和楼上上的方法不就有问题了?
      

  5.   

    string FileName=文件名;//包括路径也没有问题
    int pos = FileName.LastIndexOf(".");
    string FileType = FileName.Substring(pos);
      

  6.   

    FileInfo fi=new FileInfo("f:\123\12345.asp");
    string ext=fi.Extension
      

  7.   

    FileInfo  fio= New FileInfo(@"f:\123\12345.html");
    string Extension  = fio.Extension();or string Extension  =Path.GetExtension(@"f:\123\12345.html");