字符串路径忽略直到最后\ [英] string path ignore till last \
本文介绍了字符串路径忽略直到最后\的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在运行时,我们可以从下面找到任何路径,
at run time we can have any path from below,
path=d:\abxyz.xml
path=d:\abcmn\a\xyiopoipoz.xml
path=d:\abc\a\bsa\xysaz.xml
我只想获取XML文件的名称..这意味着我想忽略字符串直到最后\ ....
现在,我正在通过path.substring(#).
进行硬编码
在此先感谢
I want to get only the name of XML file.. mean that i want to ignore the string till last \....
rite now i am hardcoding by path.substring(#).
Thanks in advance
推荐答案
在lastndexof
中使用子字符串属性
use substring propery with lastndexof
String a = "YOUR PATH";
String b = "";
if(a.Contains(@"\\"))
{
b = a.Substring(a.LastIndexOf(@"\")+1);
}
问候
塞巴斯蒂安
Regards
Sebastian
这篇关于字符串路径忽略直到最后\的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文