Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/01/2008, 17:34
Avatar de seba123neo
seba123neo
 
Fecha de Ingreso: febrero-2007
Ubicación: Esperanza, Santa Fe
Mensajes: 1.046
Antigüedad: 17 años, 3 meses
Puntos: 19
Re: Urgente, confirmar si archivo existe

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.
__________________
" Todos Somos Ignorantes; lo que pasa es que no todos ignoramos las mismas cosas " - Albert Einstein