【发布时间】:2011-05-26 15:59:49
【问题描述】:
尝试以递归方式删除设定大小的 .exe 文件 - 但 VBscript 不是我的强项,有人能看出它不能递归工作的明显原因吗?
OPTION EXPLICIT
DIM strFolder
DIM objFSO
strFolder = "C:\TESTFOLDER"
set objFSO = createobject("Scripting.FileSystemObject")
RecursiveDelete strFolder
wscript.echo "Finished"
sub RecursiveDelete(byval strDirectory)
DIM objFolder, objSubFolder, objFile
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
if ( RIGHT(UCASE(objFile.Path),4) = ".EXE" ) AND (file.Size == 47232 ) then
wscript.echo "Deleting:" & objFile.Path
objFile.Delete
end if
next
for each objSubFolder in objFolder.SubFolders
RecursiveDelete objSubFolder.Path
next
end sub
【问题讨论】:
-
下次,请尝试更具体地说明错误,即比“不工作”更具描述性。
-
Apols。它正在工作,只是没有递归 - 即“没有递归工作”