字符串替换

terranliu 2010-10-19 12:41:19
用string reportPath = Application.StartupPath;得到reportPath 的值是D:\CZQ\CZQ\CZQ\bin\F_Report_Data.cs,我现在想把这个字符串倒数第二个‘\’后面的的bin\F_Report_Data.cs替换成Report\CrystalReport1.rpt
请大侠给支支招,谢谢!
...全文
97 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
事理 2010-10-19
  • 打赏
  • 举报
回复
俺不是大侠

string reportPath = Application.StartupPath;
reportPath=reportPath.Substring(0,reportPath.IndexOf("bin"))+"Report\CrystalReport1.rpt";

孟子E章 2010-10-19
  • 打赏
  • 举报
回复
String s = @"D:\CZQ\CZQ\CZQ\bin\F_Report_Data.cs";
s = s.Substring(0,s.LastIndexOf("\\"));
s = s.Substring(0, s.LastIndexOf("\\"));
s+=@"\Report\CrystalReport1.rpt"'

111,129

社区成员

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

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

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