Resolving relative to absolute path in ASP.NET
Resolving relative paths to absolute paths isn’t that hard when you’re working with normal system paths. You can simply use System.IO.Path.GetFullPath("./relative_path");
However when working with ASP.NET, this can be a little trickier. Because the current folder depends on the code that is calling your code, which switches around a bit in ASP.NET.
The best way to do so is by using the Server.MapPath method:
System.Web.HttpContext.Current.Server.MapPath("~/subfolder/file.text")
Piece of cake.
No Responses to “Resolving relative to absolute path in ASP.NET”.
Leave a response