学习..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
public static string SubDisk(string str) {
string a="C:\\Documents and Settings\\Administrator\\桌面\\";
return str.Substring(0,str.Length);
}
string [] array = str.Split(new char[] { '\\'});
Console.WriteLine(array[array.Length - 1].ToString());
")
public static string SubDisk(string str) {
string a="C:\\Documents and Settings\\Administrator\\桌面\\";
return str.Substring(a.Length, str.Replace(a,"").Length);
}写错啦
string str = @"C:\Documents and Settings\Administrator\桌面\A0A.xls";
string strName = str.Substring(str.LastIndexOf("\\"));