Server.MapPath to go two folder back from root

Total Post:1

Points:7
C#  .NET 
C#
 372  View(s)
Ratings:
Rate this:

this I have done

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

I want to go two folder back from the root

  1. Post:2

    Points:14
    Re: Server.MapPath to go two folder back from root

    If you really need the grandparent path, you can get it from the root path using Path.GetDirectoryName():


    string root = Server.MapPath("~"); string parent = Path.GetDirectoryName(root); string grandParent = Path.GetDirectoryName(parent);

    hope it resolves your problem

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!