C#中关于字符串处理的疑问
夏黑26 2009-12-01 02:52:54 string path = e.CommandArgument.ToString();
path = path.Replace(FileSystemManager.GetRootPath(), "~");
path = path.Replace("\\", "/");
Response.Redirect(path);
FileSystemManager.GetRootPath()这个方法实现的是活的根目录。代码如下:
private static string strRootFolder;
static FileSystemManager() {
strRootFolder = HttpContext.Current.Request.PhysicalApplicationPath;
strRootFolder = strRootFolder.Substring(0,strRootFolder.LastIndexOf(@"\"));
}
/// <summary>
/// 读根目录
/// </summary>
/// <returns></returns>
public static string GetRootPath() {
return strRootFolder;
}
现在有疑问:第二行(加红色的那一行)的作用是什么呢,该行执行完之后path的值是什么呢?
根路径是:D:\Visual Studio 2005\projects\myProject\My\Web文件管理\Web文件管理