Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Virtual or Physical Path ?

Posted on 2013-11-01
6
Medium Priority
?
481 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 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
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.

 
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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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/…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

704 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