学习..string str = @"C:\Documents and Settings\Administrator\桌面\A0A.xls";
Console.WriteLine(Path.GetFileName(@"C:\Documents and Settings\Administrator\桌面\A0A.xls"));   //A0A.xls
Console.WriteLine((str.Substring(str.LastIndexOf(@"\"), str.Length - str.LastIndexOf(@"\"))).Replace(@"\", ""));   //A0A.xls

解决方案 »

  1.   


    public static  string SubDisk(string str) { 
                string a="C:\\Documents and Settings\\Administrator\\桌面\\";
                return str.Substring(0,str.Length);
            }
      

  2.   

                string str =@"C:\Documents and Settings\Administrator\桌面\A0A.xls";
                string [] array = str.Split(new char[] { '\\'});
                Console.WriteLine(array[array.Length - 1].ToString());
      

  3.   

    string result = System.IO.Path.GetFileName(@"C:\Documents and Settings\Administrator\桌面\A0A.xls
    ")
      

  4.   


    public static  string SubDisk(string str) { 
                string a="C:\\Documents and Settings\\Administrator\\桌面\\";
                return str.Substring(a.Length, str.Replace(a,"").Length);
            }写错啦
      

  5.   

    用lastindexof返回最后/的索引下标,再用子字符串函数从该下标截取到末尾。
      

  6.   


    string str = @"C:\Documents and Settings\Administrator\桌面\A0A.xls";
    string strName = str.Substring(str.LastIndexOf("\\"));