我用 Kill "C:\Documents and Settings\Programer\Local Settings\Temporary Internet Files\*.*" 想删除ie临时文件,但是运行的时候提示“文件未找到“,究竟是为什么呢?

解决方案 »

  1.   

    C:\Documents and Settings\Programer\Local Settings\Temporary Internet Files\确实存在???
      

  2.   

    winxp目录与文件确实存在,我用explorer看过里面是有很多文件的。
      

  3.   

    '模 块 名:IsPath
    '功    能:判断有没有这个路径
    '返 回 值:成功/失败:True/False
    '参    数:IsPath(要判断的路径)
    '引    用:无
    '外部函数:无
    '内部变量:无
    '调用方法:MsgBox IsPath("C:\Windows")
    Public Function IsPath(ByVal Path As String) As Boolean
        On Error GoTo 1
        IsPath = False
        MkDir Path
        RmDir Path
        Exit Function
    1:
        IsPath = True
    End Function'模 块 名:IsFile
    '功    能:判断有没有这个文件
    '返 回 值:成功/失败:True/False
    '参    数:IsFile(要判断的文件)
    '引    用:无
    '外部函数:无
    '内部变量:[FileID=打开的文件的文件号]
    '调用方法:MsgBox IsFile("C:\Autoexec.Bat")
    Public Function IsFile(FileName As String) As Boolean
        On Error Resume Next
        Dim FileID As Long
        FileID = FreeFile()
        Open FileName For Input As #FileID
        Close #FileID
        IsFile = (Err.Number = 0)
        Err.Clear
    End Function'模 块 名:GetFolderList
    '功    能:返回指定文件夹的所有文件夹列表
    '返 回 值:成功/失败:True/False
    '参    数:GetFileList(指定文件夹路径, 文件夹数组)
    '引    用:无
    '外部函数:无
    '内部变量:[SearchDir=路径][FoundDir=文件夹名][i=用于循环]
    '调用方法:
    '++++++++++++++++++++++++++++++++++++
    '   Dim FolderName() As String, i As Long
    '   GetFileList "c:\", FolderName
    '   For i = 0 To UBound(FolderName)
    '       Debug.Print FolderName(i)
    '   Next i
    '++++++++++++++++++++++++++++++++++++
    Public Function GetFolderList(ByVal Path As String, ByRef FolderName() As String) As Boolean
        Dim SearchDir As String
        Dim FoundDir As String
        Dim i As Long
        If right(Path, 1) <> "\" Then Path = Path & "\"
        SearchDir = Path & "\*."
        FoundDir = Dir(SearchDir, vbDirectory)
        While FoundDir <> ""
            If Not FoundDir = "." Or FoundDir = ".." Then FolderName(i) = FoundDir
            FoundDir = Dir()
            i = i + 1
        Wend
    End Function'模 块 名:GetFileList
    '功    能:返回指定文件夹的所有文件名列表
    '返 回 值:成功/失败:True/False
    '参    数:GetFileList(指定文件夹路径, 文件数组)
    '引    用:无
    '外部函数:无
    '内部变量:[fName=文件名][i=用于循环]
    '调用方法:
    '++++++++++++++++++++++++++++++++++++
    '   Dim FileName() As String, i As Long
    '   GetFileList "c:\", FileName
    '   For i = 0 To UBound(FileName)
    '       Debug.Print FileName(i)
    '   Next i
    '++++++++++++++++++++++++++++++++++++
    Function GetFileList(ByVal Path As String, ByRef FileName() As String) As Boolean
        Dim fName As String
        Dim i As Long
        If right$(Path, 1) <> "\" Then Path = Path & "\"
        fName = Dir$(Path & "*.*")
        i = 0
        Do While fName <> ""
            ReDim Preserve FileName(i) As String
            FileName(i) = fName
            fName = Dir$
            i = i + 1
        Loop
        If i <> 0 Then
            ReDim Preserve FileName(i - 1) As String
            GetFileList = True
        Else
            GetFileList = False
        End If
    End Function
    ==========================
    Copy的,没有用也不要骂我哦!
      

  4.   

    Private Sub Form_Load()
        Dim FolderName() As String, i As Long
        Dim P As String
        P = "c:\windows\temp\"
        If IsFile(P) Then
            GetFileList P, FolderName
            For i = 0 To UBound(FolderName)
                Kill P & FolderName(i)
            Next i
        End If
    End Sub