server. MapPath 问题

来源:互联网 发布:监测 移动数据造假 编辑:程序博客网 时间:2024/04/29 17:37

  public static string GetMapPath(string virtualPath)        {            if (virtualPath == null)            {                return "";            }            else if (virtualPath.StartsWith("~/"))            {                return virtualPath.Replace("~/", AppDomainAppPath).Replace("/", "\\");            }            else            {                return Path.Combine(AppDomainAppPath, virtualPath.Replace("/", "\\"));            }        }

在   String strPath = System.Web.HttpContext.Current.Server.MapPath("test.txt");


string strPath=Server.MapPath("test.txt")


在MVC中   controller里,使用这个  Server.GetMapPath("~/ImagesFile/");


0 0
原创粉丝点击