dir(路径文件名),如果文件不存在返回-1!

解决方案 »

  1.   

    Dim fso As New FileSystemObject
     If fso.FileExists("你的目录" & "\" & "文件名") Then
        MsgBox "文件存在在该目录中!"
     Else
        MsgBox "文件不存在在该目录中!"
     End If
      

  2.   

    winAPI
    findFirstFile
    findNextFile
      

  3.   


    Public Function MyDir(strFile) As Boolean
        On Error GoTo errH
        If Dir(strFile) <> "" Then
            MyDir = True
        Else
            MyDir = False
        End If
        Exit Function
    errH:
        MyDir = False
    End Function
    '用法:
    Private Sub Command1_Click()
        MsgBox MyDir(Text1.Text)
    End Sub