Solved

Virtual or Physical Path ?

Posted on 2013-11-01
6
473 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Author Closing Comment

by:dwe0608
Comment Utility
Works a treat - thanks greatly.
0
 
LVL 11

Expert Comment

by:MajorBigDeal
Comment Utility
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
Comment Utility
Glad I could help!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

9 Experts available now in Live!

Get 1:1 Help Now