Hola,aca te paso algunas formas:
Código:
Private Sub Form_Load()
On Error GoTo Falso
archivo = GetAttr("C:\archivo.txt")
MsgBox "El fichero existe", 32, "Archivo"
Exit Sub
Falso:
MsgBox "El fichero no existe", vbExclamation, "Archivo"
End Sub
aca otra forma,con una funcion que usa la librearia Microsoft Scripting Runtime, debes agregarla en el menu
Proyecto-->Referencias.
Código:
Private Function Existe(ruta As String) As Boolean
Dim busca As Scripting.FileSystemObject
Set buscar = New Scripting.FileSystemObject
If (buscar.FileExists(ruta)) Then
Existe = True
MsgBox "Existe el archivo"
Else
Existe = False
MsgBox "No existe el archivo"
End If
Set buscar = Nothing
End Function
Private Sub Form_Load()
Existe ("c:\archivo.txt")
End Sub
con
Len:
Código:
Private Sub Form_Load()
Dim sRuta As String
Dim sExiste As String
sRuta = "C:\Calc.Exe"
sExiste = Dir("c:\db.txt")
If Len(sExiste) > 0 Then
MsgBox "El archivo Existe"
Else
MsgBox "El archivo no Existe"
End If
End Sub
con
Dir:
Código:
If Dir("C:\Archivo.txt") <> "" then
MsgBox "Existe el Archivo"
Else
MsgBox "No Existe el Archivo"
End If
ojala te sirva alguno...
saludos.