[简单]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( '/ '));