得到网站下的文件虚拟路径的方法

public string GetUrl_Path()
{
string url = "http://" + HttpContext.Current.Request.Url.Host;
string url_sub = HttpContext.Current.Request.ApplicationPath;
if (url_sub == "/") { url_sub = ""; }
url = url + url_sub;
return url;
}

虚拟路径: theUrl = geturl.GetUrl_Path() + "/WorkData/Pgbg_Doc/" + this.Hd_dtmc.Value;

与该虚拟路径相对应的物理路径:

 theURL = HttpContext.Current.Server.MapPath("../WorkData/Pgbg_Doc/") + this.Hd_dtmc.Value;

posted @ 2016-08-24 09:40  路小乙  阅读(266)  评论(0编辑  收藏  举报