【问题标题】:cannot find file when accessing via virtual directory in classic asp通过经典asp中的虚拟目录访问时找不到文件
【发布时间】:2012-12-10 20:23:28
【问题描述】:

我正在通过服务器对象使用经典 asp 访问虚拟文件夹中的文件。这是获取文件夹的代码:

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Dim mapPath
mapPath = Server.MapPath("http://development/far/")
Set farFolder = FSO.GetFolder(mapPath)

循环浏览目录时出现文件未找到错误。当我将 //development/far/ 放在浏览器中时,可以看到这些文件。我对asp还很陌生,所以不知道哪里出了问题。

这是循环目录时的代码:

For Each item in farFolder.Files

Set matches =  re.Execute(item.Name)
if(matches.Count=1) then
Response.Write ("<a target=""_blank""href=""" & item.Path & """>" & item.Name & "</a>  <br>")
End if

Next

【问题讨论】:

  • 向我们展示循环目录并产生文件未找到错误的代码。

标签: asp-classic vbscript virtual-directory file-not-found


【解决方案1】:

调用Server.MapPath()时只需使用URL的路径部分:

mapPath = Server.MapPath("/far/")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多