Hi
I am using System.IO.Directory.GetCurrentDirectory() to get the current directory in my web service, but that does not give me the current directory. How do I get the current directory in a web service?
Thanks Stuart
Hi
I am using System.IO.Directory.GetCurrentDirectory() to get the current directory in my web service, but that does not give me the current directory. How do I get the current directory in a web service?
Thanks Stuart
In a webservice, you are running in a http context. So,
HttpContext.Current.Server.MapPath("~/")
will give you the answer.
HttpContext.Current.Server.MapPath("~/") would get you the root of the application?
Which is plenty most likely as you probably know the path from there.
A difference which might be of interest
HttpContext.Current.Server.MapPath("/Directory/") builds from the root of the application no matter what
HttpContext.Current.Server.MapPath("Directory/") without the first slash this will take directory from where you call as the start.
I believe HttpContext.Current.Server.MapPath(".") will give you the current working directory