[Función]Exist file

Topic created · 4 Mensajes · 862 Visitas
  • [alinear-centro]Imagino que por el título ya sabréis de que vá :

    '------------------------------------------------------
    'Coded By The Swash
    'the_swash@hotmail.es
    'www.Indetectables.net & www.Leandroascierto.com.ar
    'Exist Function if know File Exist
    '------------------------------------------------------
    Public Function Exist(file As String)
     On Error Resume Next
      Exist = GetAttr(file)
     Exit Function
    End Function  
    

    Para usar :

     If Exist(your file path) Then
      MsgBox"My File Exist"
      Else
      MsgBox"My File Not Exist"
     End If  
    

    Los comentarios de la función los podeis omitir.[/alinear-centro]

  • que quieres que te diga, bien que estes aprendiendo vb.net, pero sale mas rentable poner file.exist que una funcion completa mas.

    If File.Exists(path) Then
    //el archivo existe
    else
    //el archivo no existe
    end if

  • @jumarras said:

    que quieres que te diga, bien que estes aprendiendo vb.net, pero sale mas rentable poner file.exist que una funcion completa mas.

    If File.Exists(path) Then
    //el archivo existe
    else
    //el archivo no existe
    end if

    No estoy aprendiendo .net , lo usé en su época y de momento de basic solo uso vb6 , estoy en lenguajes de script.

    Quise poner la función porque me ayudó en un par de proyectos.

    Saludos.

  • No sé si será para VB.NET pero también existen otros:

    If My.Computer.Filesystem.FileExist("path") then
    'code
    End if