在ASP Classic应用程序中获取根目录

Cav*_*rob 7 directory path asp-classic

我的ASP Classic应用程序中有几个相对路径.为了设置路径,我想获得对我的特定应用程序的根目录的引用(因为服务器的根目录是不同的).

有没有办法做到这一点?

mat*_*ieu 8

你有没有尝试过

<%= Server.MapPath("/") %>
Run Code Online (Sandbox Code Playgroud)


Li *_*hen 7

使用Request.ServerVariables("APPL_MD_PATH")Request.ServerVariables("APPL_PHYSICAL_PATH")

  • “ Request.ServerVariables(“ APPL_PHYSICAL_PATH”)`对我有用。谢谢! (2认同)

Cav*_*rob -1

我找到了一种使用一些服务器变量来做到这一点的方法。任何人都可以通过这种方式保证任何可能的错误吗?

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
Run Code Online (Sandbox Code Playgroud)