帮帮我!!!帮帮我!!!
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