PrivateSubCommand1_Click()
DimstrPathNameAsString 字串1
strPathName="" 字串4
strPathName=InputBox("请输入需要删除的文件夹名称∶","删除文件夹") 字串9
IfstrPathName=""ThenExitSub 字串5
OnErrorGoToErrorHandle 字串7
SetAttrstrPathName,vbNormal'此行主要是为了检查文件夹名称的有效性 字串7
RecurseTreestrPathName
Label1.Caption="文件夹"&strPathName&"已经删除!"
字串2
ExitSub
ErrorHandle:
字串1
MsgBox"无效的文件夹名称:"&strPathName
EndSub 字串9
SubRecurseTree(CurrPathAsString) 字串6
DimsFileNameAsString 字串2
DimnewPathAsString
DimsPathAsString 字串3
StaticoldPathAsString 字串6
sPath=CurrPath&"\"
sFileName=Dir(sPath,31)'31的含义∶31=vbNormal vbReadOnly vbHidden vbSystem vbVolume vbDirectory
字串5
DoWhilesFileName<>""
IfsFileName<>"."AndsFileName<>".."Then 字串4
IfGetAttr(sPath&sFileName)AndvbDirectoryThen'如果是目录和文件夹 字串3
newPath=sPath&sFileName
RecurseTreenewPath 字串8
sFileName=Dir(sPath,31)
字串4
Else 字串5
SetAttrsPath&sFileName,vbNormal 字串4
Kill(sPath&sFileName) 字串8
Label1.Caption=sPath&sFileName'显示删除过程 字串8
sFileName=Dir
EndIf 字串2
Else 字串6
sFileName=Dir
字串5
EndIf
字串6
DoEvents
Loop
SetAttrCurrPath,vbNormal
字串4
RmDirCurrPath
字串7
Label1.Caption=CurrPath 字串3
EndSub 字串7
->字串1