请教字符串截取算法,取指定标识的字符串内容

daviddivad 2018-04-09 03:08:11
下面这段内容:
"<?xml version="1.0" encoding="utf-8"?>
<uploadResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<IsSuccess>true</IsSuccess>
<FileSavePath>E:\ceshi\UserFiles\wx41f139a7128dd7ea.o6zAJs6lmcL-5-PjOPxjBxyOI_ys.DlHPAamrxGWf1e88b45a67fb9aa7ca0edc49fa87cde2.jpg</FileSavePath>
</uploadResult>"

想获取<FileSavePath></FileSavePath>中的文件名内容,不需要路径,即字符串函数返回“wx41f139a7128dd7ea.o6zAJs6lmcL-5-PjOPxjBxyOI_ys.DlHPAamrxGWf1e88b45a67fb9aa7ca0edc49fa87cde2.jpg”

最好写成函数,参数为整个字符串内容,返回文件名
...全文
270 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
江湖小虾仁 2018-04-09
  • 打赏
  • 举报
回复
截取字符串用substring就行了 string strResult = str.Substring(str.LastIndexOf(@"\")+1); 你不会是要把配置文件整个当参数穿进去吧。

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧