问题描述
FROM LABO VAN VOOREN \ Geomeasuring&分析nv \ BORING \ gfh \ 171210 \ attendence.pdf
上面提到的是一个字符串.我想从中获取子字符串.
我只想使用子字符串''attendence.pdf''
同样
来自LABO VAN VOOREN \ Geomeasuring& nv \ BORING \ gfh \ 171210 \ fromtheliveofthearticle.pdf
我只想使用子字符串"fromtheliveofthearticle.pdf"
等
需要的是,每次我得到像上面的字符串这样的路径时,每次我只想要"\"符号后的姓氏.
请帮助解决此问题
Kishore
FROM LABO VAN VOOREN\Geomeasuring & Analysis nv\BORING\gfh\171210\attendence.pdf
The above mentioned is a string.i want to take substring from that.
i want to take the substring ''attendence.pdf'' only
Similarly
FROM LABO VAN VOOREN\Geomeasuring & Analysis nv\BORING\gfh\171210\fromtheliveofthearticle.pdf
i want to take the substring ''fromtheliveofthearticle.pdf'' only
etc
The need is that every time i get a path like the string above,each time i want only the last name after ''\'' symbol.
Kindly help to solve this
Kishore
推荐答案
String strOutput = String.Empty;
//attendence.pdf
String strTemp=@"FROM LABO VAN VOOREN\Geomeasuring & Analysis nv\BORING\gfh\171210\attendence.pdf";
String [] strArray = strTemp.Split(new Char [] {'\\'});
strOutput = strArray[strArray.Length - 1];//attendence.pdf
//fromtheliveofthearticle.pd
strTemp = @"FROM LABO VAN VOOREN\Geomeasuring & Analysis nv\BORING\gfh\171210\fromtheliveofthearticle.pdf";
strArray = strTemp.Split(new Char[] { '\\' });
strOutput = strArray[strArray.Length - 1]; //fromtheliveofthearticle.pd
谢谢,
Mamun
Thanks,
Mamun
string path = @"FROM LABO VAN VOOREN\Geomeasuring & Analysis nv\BORING\gfh\171210\attendence.pdf";
string fileName = path.Substring(path.LastIndexOf("\\") + 1);
这篇关于Asp.net子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!