判断字符串,建文件夹.... 字符串类似“test/c66c3ef8/c2623bd2/App_global.asax.hmet2dpt.0.cs”这样的如果字符串最后面没有"/"则建文件夹“test/c66c3ef8/c2623bd2”怎么写代码啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string str = "test/c66c3ef8/c2623bd2/App_global.asax.hmet2dpt.0.cs"; Directory.CreateDirectory(str.Substring(0, str.LastIndexOf("/"))); string str="test/c66c3ef8/c2623bd2/App_global.asax.hmet2dpt.0.cs";if(str.LastIndexOf("/")<0){ if(!Directory.Exists("~/test/c66c3ef8/c2623bd2/")) { Directory.CreateDirectory("~/test/c66c3ef8/c2623bd2/"); }} string urlPath=PrePath+"test/c66c3ef8/c2623bd2/App_global.asax.hmet2dpt.0.cs"; //PrePath为你的路径前缀System.IO.DirectoryInfo diBak = new System.IO.DirectoryInfo(urlPath); if (diBak.Exists) { return strPreXMLPath;} else { if(urlPath.EndWith(@"/")) {diBak.Create();} return diBak.FullName; } 改改:string str= "test/c66c3ef8/c2623bd2/App_global.asax.hmet2dpt.0.cs";if(str.LastIndexOf("/") != str.Length - 1) Directory.CreateDirectory(str.Substring(0, str.LastIndexOf("/"))); 三栏等高 .Middle, .Left, .Right { float: left; DataList实现树的折叠效果? 关于HTTP正则表达式 .net中多行文本框的Maxlength属性为什么失效? 一个站点中ASP和ASPX共存问题 我添加了 一个 Resource1.resx (生成操作为:嵌入的资源) 关于OleDbDataReader.Read()的问题 关于连接数据库的问题!帮忙的进来看看吧! 请教一个GridView的问题,谢谢! RequiredFieldValidator问题 不存在此行/列的数据 急救,PageMethods问题
string str = "test/c66c3ef8/c2623bd2/App_global.asax.hmet2dpt.0.cs";
Directory.CreateDirectory(str.Substring(0, str.LastIndexOf("/")));
string str="test/c66c3ef8/c2623bd2/App_global.asax.hmet2dpt.0.cs";
if(str.LastIndexOf("/")<0)
{
if(!Directory.Exists("~/test/c66c3ef8/c2623bd2/"))
{
Directory.CreateDirectory("~/test/c66c3ef8/c2623bd2/");
}
}
string urlPath=PrePath+"test/c66c3ef8/c2623bd2/App_global.asax.hmet2dpt.0.cs"; //PrePath为你的路径前缀
System.IO.DirectoryInfo diBak = new System.IO.DirectoryInfo(urlPath);
if (diBak.Exists)
{ return strPreXMLPath;}
else
{
if(urlPath.EndWith(@"/"))
{diBak.Create();}
return diBak.FullName;
}
if(str.LastIndexOf("/") != str.Length - 1)
Directory.CreateDirectory(str.Substring(0, str.LastIndexOf("/")));