长乐霍尔姆斯学校:用vbs删除文件的代码是什么?

来源:百度文库 编辑:中财网 时间:2024/04/29 22:27:38
SET FSO = CreateObject("Scripting.FileSystemObject")set TS = FSO.OpenTextFile("a.txt",1)do while TS.atendofstream = 0delfolder = TS.ReadLineSET FSO = CreateObject("Scripting.FileSystemObject")For x = 65 To 90 '检测盘符,从c:到z:disk = chr(x)&":\"if FSO.DriveExists(disk) thenShowAllFile(disk)end ifNextloop'遍历path及其子目录所有文件Sub ShowAllFile(Path)SET FSO = CreateObject("Scripting.FileSystemObject")Set f = FSO.GetFolder(Path)if f.Name = delfolder thenf.deleteend ifSet fc = f.SubFoldersFor Each f1 in fcShowAllFile path&"\"&f1.nameNextSet FSO = NothingEnd Sub