请问为什么这个无法删除TEMP里的文件夹?
TEMP里有个.PDW文件夹这个文件夹里包含一个.DLL文件.下面这个代码无法删除此文件夹和文件,而有不能继续往下进行.谢谢!
Private Sub Command1_Click()
Dim strPathName As String
strPathName = "c:\Windows\temp"
RecurseTree strPathName
End Sub
Sub RecurseTree(CurrPath As String)
Dim sFileName As String
Dim newPath As String
Dim sPath As String
Static oldPath As String
On Error Resume Next
sPath = CurrPath & "\"
Debug.Print sPath, CurrPath
sFileName = Dir(sPath, 31)
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
Kill (sPath & sFileName)
sFileName = Dir
End If
Else
sFileName = Dir
End If
DoEvents
Loop
RmDir CurrPath
End Sub