Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Virtual or Physical Path ?

Posted on 2013-11-01
6
Medium Priority
?
484 Views
Last Modified: 2013-11-01
Hi Guys,

I need to determine if a file path is a virtual or physical path.

My research has yielded a function that is written in C# .Net

protected string GetPath(string path)
{
    if (Path.IsPathRooted(path))
    {
        return path;
    }

    return Server.MapPath(path);
}

Open in new window


Has someone written or aware of an equivalent function in ASP Classic? Or perhaps another means of ascertaining if a path is physical or virtual ?

MTIA

DWE
0
Comment
Question by:dwe0608
  • 4
  • 2
6 Comments
 
LVL 11

Expert Comment

by:MajorBigDeal
ID: 39618241
That function tells you if the path is absolute or relative.  If it is rooted then it is absolute, otherwise it is relative.   That is to say if it is absolute then it gives the entire location in the file system but if it is relative then it gives the location in the file system relative to another location.

 That is not the same as physical vs. virtual which has more to do with it being a file system reference to a file (physical) or a web server reference to a file (virtual).

Can you give more context on what you are doing so we'll know which is the intended distinction?
0
 
LVL 11

Accepted Solution

by:
MajorBigDeal earned 2000 total points
ID: 39618250
After rereading your example, I think this vbscript function will do what you want:

Function IsPathRooted(path)
   IsPathRooted = left(path,1) = "\" or mid(path,2,1) = ":"
End Function

according to this documentation:

http://msdn.microsoft.com/en-us/library/aa254695(v=vs.60).aspx

"A path is considered to contain a root if it starts with either a backslash (\) or with a drive letter and a colon (:)."
0
 
LVL 1

Author Comment

by:dwe0608
ID: 39618256
Hi MajorBigDeal,  what I am trying to do is work out whether a path passed into a certain function is a virtual path or a physical path ... at the moment the function simply uses a virtual path and rather than rewrite that function for using a physical path, I thought I would explore a means of testing the path to see if its virtual or not

MTIA

DWE
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Closing Comment

by:dwe0608
ID: 39618266
Works a treat - thanks greatly.
0
 
LVL 11

Expert Comment

by:MajorBigDeal
ID: 39618269
Using the assumption that in .NET a path that starts wit a tilde is a virtual path we could just do this:

Function IsVirtualPath(path)
   IsVirtualPath = (left(path,1) = "~")
End Function

A physical path in .NET would either start with a "\" or a drive letter (absolute) or an other non-tilde character (relative) so I think that will work.
0
 
LVL 11

Expert Comment

by:MajorBigDeal
ID: 39618270
Glad I could help!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question