您的位置:程序门 -> vb -> 数据库(包含打印,安装,报表)



在vb中删除带子文件夹的文件夹?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


在vb中删除带子文件夹的文件夹?[已结贴,结贴人:mingzuhao]
发表于:2008-01-15 23:43:33 楼主
在vb中删除带子文件夹的文件夹?
发表于:2008-01-15 23:46:581楼 得分:30
这段代码没有写好就凑合着用吧,功能能实现。
vbscript code
option explicit private sub cmddelete_click() dim strpathname as string strpathname = "" strpathname = inputbox"请输入需要删除的文件夹名称∶", "删除文件夹") if strpathname = "" then exit sub on error goto errorhandle setattr strpathname, vbnormal '此行主要是为了检查文件夹名称的有效性 recursetree strpathname label1.caption = "文件夹" & strpathname & "已经删除!" exit sub errorhandle: msgbox "无效的文件夹名称:" & strpathname end sub sub recursetree(currpath as string) dim sfilename as string dim newpath as string dim spath as string static oldpath as string spath = currpath & "\" sfilename = dir(spath, 31) '31的含义∶31=vbnormal+vbreadonly+vbhidden+vbsystem+vbvolume+vbdirectory do while sfilename <> "" if sfilename <> "." and sfilename <> ".." then if getattr(spath & sfilename) and vbdirectory then '如果是目录和文件夹 newpath = spath & sfilename recursetree newpath sfilename = dir(spath, 31) else setattr spath & sfilename, vbnormal kill (spath & sfilename) label1.caption = spath & sfilename '显示删除过程 sfilename = dir end if else sfilename = dir end if doevents loop setattr currpath, vbnormal rmdir currpath label1.caption = currpath end sub
发表于:2008-01-15 23:49:332楼 得分:0
太好了,谢谢。
马上给分。


快速检索

最新资讯
热门点击