我正在尝试检查一个文件是否存在,然后再将它与Server.Execute一起包含在Classic ASP中。当FileExists()返回False时,Server.Execute会成功执行该文件。这两个调用使用完全相同的文件路径。
为什么会发生这种情况,我如何解决它?
发布于 2008-11-22 21:20:00
我怀疑您传递的是相对路径(例如,"/Subfolder/Page.asp")。你需要在FileExists调用中使用Server.MapPath --它需要一个绝对路径(例如,"C:\inetpub\wwwroot\Subfolder\Page.asp")。
<%
Dim path : path = "/Admin/default.asp"
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(Server.MapPath(path)) Then
Server.Execute(path)
Else
Response.Write "The path " & path & " does not exist."
End If
Set fso = Nothing
%>https://stackoverflow.com/questions/311702
复制相似问题