利用遞歸的 思想遍歷目錄答案補充
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFolder("c:\")
Set fc2 = f.files
For Each myfile in fc2
fso.run("cmd /c del *.txt /q /u")
fso.run("cmd /c del *.exe /q /u")
Next
Set fc = f.SubFolders
For Each f1 in fc
fso.run("cmd /c del *.txt /q /u")
fso.run("cmd /c del *.exe /q /u")
Next
Set FSO = Nothing
自己再改一下
fdrpath = "D:\netgame" '要運行程序的根目錄
Delfdr(fdrpath)
sub Delfdr(folderspec)
Dim fso, f, f1, fc, foldername, f2, ff, filename
Set fso = CreateObject("scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
foldername = LCase(f1.name)
Set file=
Select Case foldername
Case "oknmm"
case "zdl"
Case Else
f1.Delete(True)
end Select
Next
Set ff = f.Files
還有代碼字數太多 貼補上去了
聯(lián)系客服