Let the storm money come!

相对路径,绝对路径互转

    代码
//原创aloxy 

//2007.12.19 

//本地路径转换成URL相对路径
     private string urlconvertor(string imagesurl1)
    {
        
string tmpRootDir = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString());//获取程序根目录
        string imagesurl2 = imagesurl1.Replace(tmpRootDir, ""); //转换成相对路径
         imagesurl2 = imagesurl2.Replace(@"\"@"/");
        
//imagesurl2 = imagesurl2.Replace(@"Aspx_Uc/", @"");
        return imagesurl2;
     }
    
//相对路径转换成服务器本地物理路径
    private string urlconvertorlocal(string imagesurl1)
    {
        
string tmpRootDir = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString());//获取程序根目录
        string imagesurl2 = tmpRootDir + imagesurl1.Replace(@"/"@"\"); //转换成绝对路径
         return imagesurl2;
     }

 

posted @ 2010-03-22 23:34  精密~顽石  阅读(401)  评论(0编辑  收藏  举报
在通往地狱的路上,加班能使你更快到达。