您当前位置:编程帮手 > 知识 > 知识 > C# > 常用代码 > 内容
代码库
2015-12-03 15:46:17 访问(1940) 赞(0) 踩(0)
/// <summary> /// 通过完整路径(包括网页路径),获得文件名 /// </summary> /// <param name="str"></param> /// <returns></returns> public string ToFileName(string str) { int idxOne = str.LastIndexOf("/"); int idxTwo = str.LastIndexOf("\\"); if (idxOne == -1 && idxTwo == -1) { return str; } if (idxTwo > idxOne) return str.Substring(idxTwo + 1); else return str.Substring(idxOne + 1); }
上一条:
下一条: