Reputation: 75504
Is there a built-in asp.net method for checking the "virtualness" of a path?
The only way I've been able to do it so far is with the following try block:
public void Foo(String path){
try
{
path = Server.MapPath(path);
}
catch(HttpException){}
// do stuff with path
}
Upvotes: 1
Views: 533
Reputation: 10013
Here is everything you need to know about ASP.Net paths: Rick Strahl's post "Making Sense of ASP.Net Pahts"
Upvotes: 3
Reputation: 19791
Would the Path.IsPathRooted method work?
You're resulting code would be:
public void Foo(String path)
{
if(!Path.IsPathRooted(path))
{
path = Server.MapPath(path);
}
// do stuff with path
}
Upvotes: 3