Autor Tema: Saber si archivo tipo imagen existe  (Leído 2762 veces)

0 Usuarios y 1 Visitante están viendo este tema.

lucius

  • Gigabyte
  • ****
  • Mensajes: 263
  • Reputación: +6/-5
    • Ver Perfil
Saber si archivo tipo imagen existe
« en: Noviembre 28, 2011, 08:11:13 pm »
Quiero cargar una imagen de equiz extencion .bmp . jpg etc atravez del nombre pero el problema esta ahi osea si intento cargar imagen.bmp y el archivo se llama imagen.jpg entonces me tira error.

Actualmente lo hago asi pero hay algun otro metodo o como lo hago correctamente.

Código: [Seleccionar]
Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long

Private Sub Command1_Click()

If CStr(CBool(PathFileExists(App.Path & "\xarchivo.jpg"))) = True Then
   MsgBox "existe xarchivo.jpg"
ElseIf CStr(CBool(PathFileExists(App.Path & "\xarchivo.bmp"))) = True Then
   MsgBox "existe xarchivo.bmp"
ElseIf CStr(CBool(PathFileExists(App.Path & "\xarchivo.gif"))) = True Then
   MsgBox "existe xarchivo.gif"
Else
   MsgBox "no existe ningun archivo del tipo imagen"
End If

End Sub

seba123neo

  • Terabyte
  • *****
  • Mensajes: 763
  • Reputación: +88/-5
    • Ver Perfil
Re:Saber si archivo tipo imagen existe
« Respuesta #1 en: Noviembre 29, 2011, 01:35:00 am »
ese CStr() no es necesario. hay varias formas GetAttr() o estas:

Como verificar si un archivo existe

saludos.

79137913

  • Megabyte
  • ***
  • Mensajes: 185
  • Reputación: +21/-4
  • 4 Esquinas
    • Ver Perfil
    • Eco.Resumen Resumenes Cs. Economicas
Re:Saber si archivo tipo imagen existe
« Respuesta #2 en: Noviembre 29, 2011, 08:18:56 am »
HOLA!!!

La mas facil (no la mas rapida).

Código: (VB) [Seleccionar]
Private Sub FileExist(Path as string) as boolean
    if Len(dir( Path) ) > 0 then FileExist = True

GRACIAS POR LEER!!!
"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!"
"La peor de las ignorancias es no saber corregirlas"

 79137913                          *Shadow Scouts Team*                                                          Resumenes Cs.Economicas