dir ("x:\xxxx\某文件夹",vbdirectory )

解决方案 »

  1.   

    用下面这个函数,
    Function FileExists(FileName As String) As Boolean
        On Error Resume Next
        FileExists = (Dir$(FileName) <> "")
    End Function如果文件存在则返回真,不存在则返回假。
      

  2.   

    Dim Fso
    dim workdir as string  'workdir 是代表文件的字符串
    Set Fso = CreateObject("Scripting.FileSystemObject")
     If Fso.FolderExists(WorkDir) = True Then 
       .........
      Else: Fso.FolderExists(WorkDir) = False 
        .........
    end if
      

  3.   

    工程>>引用
    选Microsoft Scripting RuntimeDim Fso as New Scripting.FileSystemObjectFso.FileExists(FileName) 返回Boolean
    存在=True
      

  4.   

    我建议最好不要用楼上说的对象,应为如果有些系统每有安装该对象的话,除了问题你还找不到原应,可以用API实现,findfistfile()
    或者是用dir()函数,但是要注意,如果该盘符不在的话,会引起错误,例如:dir("a:\1.txt") ,如果A盘中没有软盘会报错,只要注意错误处理就行了
      

  5.   

    用dir方法。
    dir("文件路径",vbdirectory)