|
ASP编程中的路径格式转换函数及相关实例
|
|
ASP编程中的路径格式转换函数及相关实例
|
| [
作者:佚名
来源:网络整理
点击数:
更新时间:2007-6-22 ] |
|
|
|
<% ' 转为根路径格式 Function RelativePath2RootPath(url) Dim sTempUrl sTempUrl = url If Left(sTempUrl, 1) = "/" Then RelativePath2RootPath = sTempUrl Exit Function End If
Dim sWebEditorPath sWebEditorPath = Request.ServerVariables("SCRIPT_NAME") sWebEditorPath = Left(sWebEditorPath, InstrRev(sWebEditorPath, "/") - 1) Do While Left(sTempUrl, 3) = "../" sTempUrl = Mid(sTempUrl, 4) sWebEditorPath = Left(sWebEditorPath, InstrRev(sWebEditorPath, "/") - 1) Loop RelativePath2RootPath = sWebEditorPath & "/" & sTempUrl End Function
' 根路径转为带域名全路径格式 Function RootPath2DomainPath(url) Dim sHost, sPort sHost = Split(Request.ServerVariables("SERVER_PROTOCOL"), "/")(0) & "://" & Request.ServerVariables("HTTP_HOST") sPort = Request.ServerVariables("SERVER_PORT") If sPort <> "80" Then sHost = sHost & ":" & sPort End If RootPath2DomainPath = sHost & url End Function
response.Write("TestEx.<br />") response.Write("转为根路径格式:"&RelativePath2RootPath("myfolder/ggg.gif")) response.Write("<br />") response.Write("根路径转为带域名全路径格式:"&RootPath2DomainPath("/myfolder/ggg.gif")) response.Write("输出当前程序所在的目录:"&RelativePath2RootPath("")) %> |
|
|
|
|
|
打印此文 收藏此页 关闭窗口 返回顶部 |
|
|
|