我正在使用服务器对象使用经典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
调用 Server.MapPath() 时只需使用 URL 的路径部分:
mapPath = Server.MapPath("/far/")