0

I've been studying this excellent Stack post about Server.MapPath(), and I can't find anything in there that takes me up 2 levels from the current location.

Server.MapPath("./"); // this works - current path
Server.MapPath("../"); // this works - parent path
Server.MapPath("/"); // this works - virtual root path (2 levels HIGHER than I need)
Server.MapPath(".../"); // This fails

Is there no way to go up 2 levels? (That would be the parent of the parent folder.)

Yes, I can accomplish this by going to the virtual root and then parsing/combining, but that seems hackish. Looking for something more elegant or canonical.

Community
  • 1
  • 1
HerrimanCoder
  • 5,858
  • 20
  • 65
  • 111

2 Answers2

4

In windows there is no .../ path.

  • ./ means the current directory
  • ../ means one level above

Note: You can think the quantity of . are the quantity of levels, but that isn't so.

2 Levels above are ../../, 3 Levels ../../../ and so on.

Christian Gollhardt
  • 14,865
  • 16
  • 65
  • 99
3

.. goes up on folder, so ../../ will go up two levels and so on.

Note that this will not let you go outside of your site's root folder: if page is "/foo/bar.aspx" trying to map "../.." will fail if your site is at the root.

Alexei Levenkov
  • 94,391
  • 12
  • 114
  • 159