假设文件名 sfilename 路径spath
if ucase(dir(spath & sfilename))=ucase(sfilename) then
    文件存在
else
    文件不在
    创建文件
end if

解决方案 »

  1.   

    假设文件名 sfilename 路径spath
    if dir(spath & sfilename))="" then
        文件不在
        创建文件else
        文件存在
    end if 
      

  2.   

    if dir(FilePath))="" then
        '没有你要找的文件
    else
        '有要找的文件
    end if   
      

  3.   

    Public Function FileExists%(FileName$)Dim f%   ' Trap any errors that may occur
       On Error Resume Next   ' Get a free file handle to avoid using a file handle already in use
       f% = FreeFile
       ' Open the file for reading
       Open FileName$ For Input As #f%
       ' Close it
       Close #f%
       ' If there was an error, Err will be <> 0. In that case, we return False
       FileExists% = Not (Err <> 0)End Function
    应用:
    if FileExists("c:\abc.txt")=0 then '存在
        打开它吧!    
    else
        创建它吧!
        打开它吧!
    end if