Vb at the tape to delete the folder in a folder

Author:Anonymous    Updated:2008-10-28 12:04:24
OptionExplicit
PrivateSubCommand1_Click ()
DimstrPathNameAsString
StrPathName = \ "\"
strPathName = InputBox (\ "Enter the need to delete the folder name: \" \ "deleted folder \")
IfstrPathName = \ "\" ThenExitSub
OnErrorGoToErrorHandle
SetAttrstrPathName, vbNormal \ 'trip is to check the validity of the name of the folder
RecurseTreestrPathName
Label1.Caption = \ "folder \" & strPathName & \ "have been deleted! \"
ExitSub
ErrorHandle:
MsgBox \ "null and void the name of the folder: \" & strPathName
EndSub
SubRecurseTree (CurrPathAsString)
DimsFileNameAsString
DimnewPathAsString
DimsPathAsString
StaticoldPathAsString
SPath = CurrPath & \ "\ \ \"
sFileName = Dir (sPath, 31) \'31 meaning: 31 = vbNormal vbReadOnly vbHidden vbSystem vbVolume vbDirectory
DoWhilesFileName <> \ "\"
IfsFileName <> \ ". \" AndsFileName <> \ ".. \" Then
IfGetAttr (sPath & sFileName) AndvbDirectoryThen \ 'If the directory and folder
NewPath = sPath & sFileName
RecurseTreenewPath
SFileName = Dir (sPath, 31)
Else
SetAttrsPath & sFileName, vbNormal
Kill (sPath & sFileName)
Label1.Caption = sPath & sFileName \ 'shows that the deletion of the process
SFileName = Dir
EndIf
Else
SFileName = Dir
EndIf
DoEvents
Loop
SetAttrCurrPath, vbNormal
RmDirCurrPath
Label1.Caption = CurrPath
EndSub
Previous:VB with the closure of the screen protection
Next:How to get the drive letter?-Vb Guide
User Reviews
Site Search
Recommended article
AD