日期:2014-05-19  浏览次数:20869 次

[简单]Path里文件夹名称的获得
已知一个Path是文件夹路径,求得当前文件夹的名字。

例子:
c;/abc/123   or
c;/abc/123/
希望结果123


请给出最好的求法

------解决方案--------------------
string str = "c;/abc/123 ";
Console.WriteLine(str.Substring(str.LastIndexOf( '/ ') + 1, str.Length - str.LastIndexOf( '/ ') - 1));
------解决方案--------------------
楼上的正解
------解决方案--------------------
string S = @ "c:/abc/123/ ";
Text = Path.GetFileName(S.TrimEnd( '/ '));