【问题标题】:Get root directory in ASP Classic application在 ASP Classic 应用程序中获取根目录
【发布时间】:2011-03-28 14:47:48
【问题描述】:

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

有没有办法做到这一点?

【问题讨论】:

    标签: asp-classic path directory


    【解决方案1】:

    你试过了吗

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • Request.ServerVariables("APPL_PHYSICAL_PATH") 为我工作。谢谢!
      【解决方案3】:

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

      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
      

      【讨论】:

      • 你有 1 个问题,使用正则表达式,你现在有 2 个 ;)
      猜你喜欢
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多