FileExist(strFileName)
如:if(FileExist("C:\\vb.exe"))then
       do something
    end ifmaybe FileExists, I'm not sure.

解决方案 »

  1.   

    If Dir("c:\a.txt") = "" Then
    MsgBox "dddddd"
    Else
    MsgBox "d"
    End If
      

  2.   

    用dir函数(如果存在该函数返回查询的文件名,否则为空)
    dim strNameOfQuery as string
    dim strValueOfRe as stringstrNameOfQuery="c:\test.txt"
    strValueOfRe=dir(strNameOfQuery)
    if strValueOfRe=strNameOfQuery then  
       msgbox "文件存在“
    else
      msgbox "文件不存在”
    endif
      

  3.   

    用dir函数(如果存在该函数返回查询的文件名,否则为空)
    dim strNameOfQuery as string
    dim strValueOfRe as stringstrNameOfQuery="c:\test.txt"
    strValueOfRe=dir(strNameOfQuery)
    if strValueOfRe=strNameOfQuery then  
       msgbox "文件存在“
    else
      msgbox "文件不存在”
    endif
      

  4.   

    dyx(天火)提供
    Function FileExists(FileName As String) As Boolean   '判断固定文件是否存在
    '******************************************
    '* 函数说明:检查 FileName 文件是否存在   *
    '*                                        *
    '* 函数名      返回值   属性值            *
    '* -------------------------------------- *
    '* FileExists  True     文件存在          *
    '*             False    文件不存在        *
    '*                                        *
    '* 变量名      类型     属性值            *
    '* -------------------------------------- *
    '* FileName    String   被检测的文件名    *
    '******************************************
       Dim FileNum As Integer   '文件句柄号
       On Error Resume Next   '错误处理
       FileNum = FreeFile   '获取自由文件句柄
       Open FileName For Input As #FileNum   '打开被检测的文件
       Close #FileNum   '关闭文件
       FileExists = Not (Err <> 0)   '如果文件不存在(Err<>0)则(FileExitsts=False);否则相反
    End Function