Solved

Virtual or Physical Path ?

Posted on 2013-11-01
6
479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

628 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