首页

源码搜藏网

首页 > 开发教程 > Basic教程 >

删除带子文件夹的文件夹

创建时间:2013-09-18 11:38  

核心提示:SetAttrstrPathName,vbNormal此行主要是为了检查文件夹名称的有效性

OptionExplicit

PrivateSubCommand1_Click()

DimstrPathNameAsString

strPathName=""

strPathName=InputBox("请输入需要删除的文件夹名称∶","删除文件夹")

IfstrPathName=""ThenExitSub

OnErrorGoToErrorHandle

SetAttrstrPathName,vbNormal'此行主要是为了检查文件夹名称的有效性

RecurseTreestrPathName

Label1.Caption="文件夹"&strPathName&"已经删除!"

ExitSub

ErrorHandle:

MsgBox"无效的文件夹名称:"&strPathName

EndSub

SubRecurseTree(CurrPathAsString)

DimsFileNameAsString

DimnewPathAsString

DimsPathAsString

StaticoldPathAsString

sPath=CurrPath&"\"

sFileName=Dir(sPath,31)'31的含义∶31=vbNormal vbReadOnly vbHidden vbSystem vbVolume vbDirectory

DoWhilesFileName<>""

IfsFileName<>"."AndsFileName<>".."Then

IfGetAttr(sPath&sFileName)AndvbDirectoryThen'如果是目录和文件夹

newPath=sPath&sFileName

RecurseTreenewPath

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

上一篇:操作LotusNotes数据库
下一篇:定制控件编程之拦截击键动作

相关内容

热门推荐