Solved

Virtual or Physical Path ?

Posted on 2013-11-01
6
474 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now