'目录是否存在?Public Function DirExists(ByVal strDirName As String) As Boolean
    On Error Resume Next    DirExists = (GetAttr(strDirName) And vbDirectory) = vbDirectory    Err.Clear
End Function

解决方案 »

  1.   

    Option ExplicitFunction FileExists%(filename$)' Description
    '     Checks 'filename$' to find wether the filename given
    '     exists.
    '
    ' Parameters
    '     Name              Type     Value
    '     -------------------------------------------------------------
    '     filename$         String   The filename to be checked
    '
    ' Returns
    '     True if the file exists
    '     False if the file does not exist
    '
    ' Last updated by Jens Balchen 21.11.95
    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
      

  2.   

    一定要把分给我!
    假设你要找  "c:\windows" 下的 "system" 目录!
    if Dir("c:\windows\system",vbDirectory)="" then
        '--没有该目录
        ...
    else
        '---  该目录存在!
    end if
      

  3.   

    tanjianmin,可以给份了吧?
      

  4.   

    提供不用api 实现的方法:'引用 “Microsoft Scripting Runtime”'假设myPath是所判断的目录Dim tmpFileSys As New FileSystemObjectIf  tmpFileSys.FolderExists(myPath) Then '存在
         ........
    else  '不存在     .....end if