我在上传图片的时候用了server.MapPath("") 上传后的图片地址为
E:/工作文档/个人文件/wincreate/files/2008/04/19/200827191227501.jpgfiles是根目录中的一个文件夹请问怎么样才能将 E:/工作文档/个人文件/wincreate/files/2008/04/19/200827191227501.jpg
转换成
/files/2008/04/19/200827191227501.jpg

解决方案 »

  1.   

    你用Server.MapPath("").Replace(Server.MapPath("."), "")
      

  2.   

     string filePath = " E:/工作文档/个人文件/wincreate/files/2008/04/19/200827191227501.jpg ";
           string basePath= Response.Write(Server.MapPath(""));
            string path=string.Empty;
            if (filePath.IndexOf(basePath) > -1)
                path = filePath.Replace(basePath, "");
            else
                //不能转换
      

  3.   

     private void PastURL()
        {
            string strPath = @"E:/工作文档/个人文件/wincreate/files/2008/04/19/200827191227501.jpg";
            strPath = strPath.Replace(@"E:/工作文档/个人文件/wincreate/", "http://localhost/");
            strPath = strPath.Replace("\\", "/");
            Response.Write(strPath.Remove(0, 16));
        }
      

  4.   

    用Server.MapPath("").Replace(Server.MapPath("."), "")
    取得的值应为:/files/2008/04/19/