例如:首先判断是否存在“C:\ABC.TXT”文件,如果存在则删除。

解决方案 »

  1.   

    不要
    可直接用  kill "文件路径名"
    例如:
    在D盘根目录下有一个1.txt的文本文件
    就用
    Private Sub Command1_Click()
        Kill "D:\1.txt"
    End Sub
      

  2.   

    Private Sub Command1_Click()
        Kill "D:\1.txt"
    End Sub
      

  3.   

    dim strFile as string 
    strFile ="FilePath\FileName"
    if dir(strFile )<>"" then
        kill strFile 
    endif
      

  4.   

    Private Sub Command1_Click()If Dir("d:\1.txt", vbNormal) <> "" Then
        Kill "D:\1.txt"
    Else
        MsgBox "文件不存在!"
        Exit Sub
    End If
    End Sub