帮帮我!!!帮帮我!!!

zuing 2001-07-19 10:04:16
Option Explicit
Dim Name1 As String
Dim Name2 As String
Dim Path As String
Private Sub cmdDelete_Click()
On Error Resume Next
Path = "g:\ping\"
Kill (Path & "*.*")
Name1 = Dir(Path, vbDirectory)
Do While Name1 <> ""
If Name1 <> "." And Name1 <> ".." Then
Delete (Path)
End If
Name1 = Dir '为什么我调用了Delete (Path)后,name1就不会变了。如果不调用 delete (Path),name1就可以遍历目录名。
Name2 = Name1
Loop
End Sub
————————————————————————————————————
Function Delete(Path As String)
Dim Path1 As String
On Error Resume Next
Path1 = Path & Name2 & "\"
Path = Path & Name2 & "\"
Kill (Path & "*.*")
Name2 = Dir(Path, vbDirectory)
Do While Name2 <> ""
If Name2 <> "." And Name2 <> ".." Then
Path = Path & Name2
Shell "c:\windows\command\deltree.exe -y " & Path
Path = Path1
End If
Name2 = Dir
Loop
End Function
...全文
71 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Un1 2001-07-20
  • 打赏
  • 举报
回复
把Name1=Dir 改成:Name1 = Dir(Path, vbDirectory)
benlovekelly 2001-07-20
  • 打赏
  • 举报
回复
在删除name1的目录之前,你已经把name2的目录删了,当然就无法遍历目录名了。
zuing 2001-07-20
  • 打赏
  • 举报
回复
该过了,不行!!!

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧