查看: 20  |  回复: 0
  ASP 得到上级目录的地址,子程序 f_getParentPath(strThePath)
楼主
发表于 2024年10月16日 19:46
<%
function f_getParentPath(strThePath)
    '得到上级目录的地址
    'strThePath = Server.MapPath(".") '获取当前文件所在目录路径
    'strThePath = "D:\web\a.com\current" '不要\ 得到 D:\web\a.com\
    'response.write strThePath '最后不带\
    strParentPath = Left(strThePath, InStrRev(strThePath, "\")) '截取字符串获取上一级目录路径
    'response.write strParentPath '带\ 得到 D:\web\a.com\
    f_getParentPath = strParentPath
end function

strThePath = Server.MapPath(".") '获取当前文件所在目录路径
'strThePath = "D:\web\a.com\current"
response.write f_getParentPath(strThePath)
%>

运行结果:

D:\web\a.com\


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com