I am looking to get the folder that my website is running under. I have used many different methods within HttpContext.Current.Request but none of them were returning what I was looking for. I can easily get the value using substring but it doesn’t look very clean and was wondering if there was a shorthand way of getting the folder.
For example when I use the code.
HttpContext.Current.Server.MapPath("~")
I get C:\ClientProjects\Dev\v10.3\src\MySite
I can use:
HttpContext.Current.Server.MapPath("~").Substring(HttpContext.Current.Server.MapPath("~").LastIndexOf("\") + 1)
But this seems really bloated way to get the folder I’m running under.
You will be able to get the directory name from a
System.IO.DirectoryInfoobject.