Caveatrob
Caveatrob

Reputation: 13287

Get root directory in ASP Classic application

I have several relative paths in my ASP Classic application. I'd like to get a reference to the root directory of my particular application (since the root of the server is something different) for the purpose of setting paths.

Is there a way to do this?

Upvotes: 7

Views: 10466

Answers (3)

Li Chen
Li Chen

Reputation: 171

Use Request.ServerVariables("APPL_MD_PATH") or Request.ServerVariables("APPL_PHYSICAL_PATH").

Upvotes: 9

Caveatrob
Caveatrob

Reputation: 13287

I found a way to do it using some server variables. Can anyone vouch for any possible bugs this way?

function getRoot()


pathinfo=Request.ServerVariables("PATH_INFO")

Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = "^(/\w*/).*"
' Pop up a message box for each match
getRoot = myRegExp.Replace (pathinfo, "$1")


end function

Upvotes: -1

mathieu
mathieu

Reputation: 31202

Have you tried

<%= Server.MapPath("/") %>

Upvotes: 8

Related Questions