【发布时间】:2018-01-05 16:35:36
【问题描述】:
我设法写了这个,但它不起作用
<%@ Language="VBScript" %>
<!DOCTYPE html>
<html>
<body>
<%
'Delete All Subfolders and Files in a Folder And deletes itself
Function discardScript()
Set objFSO = CreateObject("Scripting.FileSystemObject")
strScript = Wscript.ScriptFullName
objFSO.DeleteFile(strScript)
End Function
Dim folderName
Dim x
Dim currentPath
Const DeleteReadOnly = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
folderName = Request.QueryString("folderName")
A = Request.ServerVariables("PATH_INFO")
response.write("PATH_INFO A: "&A&"<br />")
B = split(A,"/")
For x = LBound(B) to UBound(B)
response.write("PATH_INFO B["&x&"]: "&B(x)&"<br />")
Next
C = B(ubound(B)-1)&"/"
response.write("PATH_INFO C: "&C&"<br />")
if (folderName <> "") then
currentPath = C&folderName&"/*"
response.write("Deleting '"&folderName&"'...<br />")
if objFSO.FileExists(currentPath) then
objFSO.DeleteFile(currentPath), DeleteReadOnly
end if
objFSO.DeleteFolder(currentPath),DeleteReadOnly
else
response.write("No folder specified")
end if
'objFSO.DeleteFile("C:\FSO\*"), DeleteReadOnly
'objFSO.DeleteFolder("C:\FSO\*"),DeleteReadOnly
%>
</body>
</html>
Errore di 运行时 di Microsoft VBScript 错误 '800a004c' 不可能的 trovare il percorso /index.asp, 里加 37
这意味着:
运行时错误...找不到路径...index.asp 第 37 行
有什么想法吗?
编辑
感谢@schudel 和一些研究我得到了这个,希望它有用
<%@ Language="VBScript" %>
<!DOCTYPE html>
<html>
<body>
<%
'Delete All Subfolders and Files in a Folder And deletes itself
Function discardScript()
Set objFSO = CreateObject("Scripting.FileSystemObject")
strScript = Wscript.ScriptFullName
objFSO.DeleteFile(strScript)
End Function
Dim folderName
Dim deleteScript
Dim x
Dim fullPath
Const DeleteReadOnly = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
folderName = Request.QueryString("folderName")
BASE = Request.ServerVariables("APPL_PHYSICAL_PATH")
response.write("APPL_PHYSICAL_PATH = "&BASE&"<br />")
if (folderName <> "") then
'DELETE VARIABLES
fullPath = BASE&folderName&"\"
Set objFS = CreateObject("Scripting.FileSystemObject")
if (objFS.FolderExists(fullPath)) then
Set objFolder = objFS.GetFolder(fullPath)
Set objFiles = objFolder.Files
dim curFile
else
response.write("Folder '"&folderName&"' does not exists!")
response.End
end if
'DELETE PROCESS
response.write("Deleting content from '"&fullPath&"' ...<br />")
For each curFile in objFiles
response.write("Deleting <strong>FILE</strong>: '"&curFile&"' ...")
objFS.DeleteFile(curFile), DeleteReadOnly
Next
response.write("Deleting <strong>FOLDER</strong>: '"&objFolder&"' ...")
objFS.DeleteFolder(objFolder), DeleteReadOnly
else
response.write("No folder specified")
end if
if (deleteScript = "YES") then
discardScript()
end if
%>
</body>
</html>
【问题讨论】:
-
如果您使用的是在 ASP.NET 上运行的 Web 窗体,为什么要说“经典 ASP”并将其标记为
asp-classic,这与经典 ASP 完全不同? -
因为我需要在 Classic ASP 上执行此操作
-
如果你需要在Classic ASP上做,你为什么把它标记为ASP.NET并显示.NET代码?
-
因为我不知道这一切的区别...
-
你需要弄清楚你到底在使用什么。文件是否以 .aspx 或 asp 结尾?
标签: asp-classic windows-server-2008