rt

解决方案 »

  1.   

    简单的方法:
    if dir(app.path & "\" & 文件)="" then msgbox "不存在"高级的方法:绝对不出错
    至于文件存在检查也推荐你用api:
    Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As LongPublic Function FileExist(FileDir As String) As Integer
    '[函数]:文件是否存在
    '[参数]:被检查文件
    '[返回]:0,不存在;1,存在Dim sF As Long
    sF = GetFileAttributes(FileDir)
    FileExist = (sF <> -1)
    If sF = -1 Or sF = 0 Then
       FileExist = 0
    Else
       FileExist = 1
    End If
    End Function
      

  2.   

    引用Microsoft Scripting Runtime
    Dim mFso As FileSystemObjectSet mFso = New FileSystemObject
    If mFso.FileExists(App.Path+"\1.txt") Then 存在 Else 不存在