OptionExplicit
PrivateSubCommand1_Click
![](/icons/29366kh.gif)
DimstrPathNameAsString
strPathName=\"\"
strPathName=InputBox(\"请输入需要删除
![](/icons/29366de.gif)
IfstrPathName=\"\"ThenExitSub
OnErrorGoToErrorHandle
SetAttrstrPathName,vbNormal\'此行主要是为了检查文件夹名称
![](/icons/29366de.gif)
RecurseTreestrPathName
Label1.Caption=\"文件夹\"&strPathName&\"已经删除!\"
ExitSub
ErrorHandle:
MsgBox\"无效
![](/icons/29366de.gif)
EndSub
SubRecurseTree(CurrPathAsString)
DimsFileNameAsString
Dim
![](/icons/29366new.gif)
DimsPathAsString
StaticoldPathAsString
sPath=CurrPath&\"\\\"
sFileName=Dir(sPath,31)\'31
![](/icons/29366de.gif)
![](/icons/29366System.gif)
DoWhilesFileName<>\"\"
IfsFileName<>\".\"AndsFileName<>\"..\"Then
IfGetAttr(sPath&sFileName)AndvbDirectoryThen\'如果是目录和文件夹
![](/icons/29366new.gif)
RecurseTree
![](/icons/29366new.gif)
sFileName=Dir(sPath,31)
Else
SetAttrsPath&sFileName,vbNormal
Kill(sPath&sFileName)
Label1.Caption=sPath&sFileName\'显示删除过程
sFileName=Dir
EndIf
Else
sFileName=Dir
EndIf
DoEvents
Loop
SetAttrCurrPath,vbNormal
RmDirCurrPath
Label1.Caption=CurrPath
EndSub
最新评论