How can i use the server.mappath method in a C# class library class ,which acts as my BusinessLayer for My ASP.NET WEbsite
The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.
If the path starts with either a forward slash(/) or backward slash(\) the MapPath Method returns a path as if the path is a full virtual path. If the path doesn't start with a slash, the MapPath Method returns a path relative to a directory of the . asp file being processed.
Physical path - This is the actual path the file is located by IIS. Virtual path - This is the logical path to access the file which is pointed to from outside of the IIS application folder.
By calling it?
var path = System.Web.HttpContext.Current.Server.MapPath("default.aspx");
Make sure you add a reference to the System.Web assembly.
You can get the base path by using the following code and append your needed path with that.
string path = System.AppDomain.CurrentDomain.BaseDirectory;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With