Server.MapPath to go two folder back from root

后端 未结 5 1112
鱼传尺愫
鱼传尺愫 2020-12-30 12:12

Here is how I do it:

HttpContext.Current.Server.MapPath(@\"~\\~\\~\\Content\\\")

HI know that \'.\' is for the root of the project, but how

5条回答
  •  萌比男神i
    2020-12-30 12:30

    You can use Parent.Parent.FullName

      string grandParent  = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/")).Parent.Parent.FullName;
    

提交回复
热议问题