Hi I wonder if you guys could help please.
I\'m writing a application that is going to live on multiple servers and therefore multiple IP\'s and instead of using the
In an ASP.Net application, you can call Server.MapPath("~/path")
to resolve a path on disk relative to the application root directory.
Use Path.GetFullPath to get the absolute path from your relative path.
So, your code becomes:
string[] filePaths = Directory.GetFiles(Path.GetFullPath(@"..\BlogEngine\"), "*.xml");
Use the Server.MapPath()
method to map a relative path (based on current directory or web-site root) to an absolute accessible path.
For example:
string folderPath = Server.MapPath("~/BlogEngine");
string[] filePaths = Directory.GetFiles(folderPath, "*.xml");
The tilde character represents the root of your web-site, if you specify a relative path then it'll be resolved as relative to the directory where your ASP.NET page resides.