Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

obtener archivos

Estas en el tema de obtener archivos en el foro de Visual Basic clásico en Foros del Web. tengo un control common dialog y le he agregado flags para poder seleccionar varios archivos en cuadro de dialogo open lo que tengo es esto ...
  #1 (permalink)  
Antiguo 24/11/2005, 17:28
Avatar de satake  
Fecha de Ingreso: julio-2004
Mensajes: 140
Antigüedad: 19 años, 9 meses
Puntos: 0
obtener archivos

tengo un control common dialog y le he agregado flags para poder seleccionar varios archivos en cuadro de dialogo open
lo que tengo es esto

Código:
Private Sub Command3_Click()
CommonDialog1.Flags = cdlOFNExplorer + cdlOFNAllowMultiselect
CommonDialog1.ShowOpen
If CommonDialog1.filename = "" Then
ErrorMessage = "Debe seleccionar al menos un archivo de audio"
MsgBox (ErrorMessage)
Call Command3_Click
Else
'acá iría el código para cargar los archivos en el list
End If
End Sub
me funcion todo perfecto pero mi problema es que no se como hacer para separar los archivos y cargarlos en un list, ya que si lo cargo en un label me devuelve solo la ruta de los archivos.espero puedan ayudarme.
__________________
:aplauso: www.aponlinevillaguay.com.ar :aplauso:

Cita:
Iniciado por alguien
El arca de Noé fue hecha por principiantes, el Titanic por "profesionales".
  #2 (permalink)  
Antiguo 24/11/2005, 18:28
 
Fecha de Ingreso: abril-2005
Mensajes: 351
Antigüedad: 19 años
Puntos: 3
hola agrega dos list (list1 y list2) un command1 y un commandialg

Private Sub Command1_Click()
Dim vFiles As Variant
Dim lFile As Long
With CommonDialog1
.FileName = "" 'Clear the filename
.CancelError = True 'Gives an error if cancel is pressed
.DialogTitle = "Selecione Arhivo(s)..."
.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNHideReadOnly 'Falgs, allows Multi select, Explorer style and hide the Read only tag
.Filter = "Archivo de mapa de bits(*.bmp)|*.bmp" '"All files (*.*)|*.*"
.ShowOpen
vFiles = Split(.FileName, Chr(0)) 'Splits the filename up in segments
If UBound(vFiles) = 0 Then ' If there is only 1 file then do this
List1.AddItem .FileName
List2.AddItem .FileTitle
Else
For lFile = 1 To UBound(vFiles) ' More than 1 file then do this until there are no more files
List1.AddItem vFiles(0) + "\" & vFiles(lFile)
List2.AddItem vFiles(lFile)

Next

End If
End With

End Sub
  #3 (permalink)  
Antiguo 24/11/2005, 18:29
 
Fecha de Ingreso: abril-2005
Mensajes: 351
Antigüedad: 19 años
Puntos: 3
ahora te paso uno para evitar el commandialog.ocx y utilizar las apis

los mismo controles de antes mas un modulo y un textbox (menos el commamdialg.ocx)

en el formulario:

Option Explicit

Private Sub Command1_Click()
Dim vFiles As Variant
Dim lFile As Long
With OFN
.nStructSize = Len(OFN)
.hWndOwner = Form1.hWnd
.sFilter = "All Files" & vbNullChar & "*.*" & vbNullChar & vbNullChar
.sFile = "Untitled.bas" & Space$(1024) & vbNullChar & vbNullChar
.nMaxFile = Len(.sFile)
.sFileTitle = vbNullChar & Space$(512) & vbNullChar & vbNullChar
.nMaxTitle = Len(OFN.sFileTitle)
.sDialogTitle = "Abrir"
.flags = OFS_FILE_OPEN_FLAGS Or OFN_ALLOWMULTISELECT
End With


If GetOpenFileName(OFN) Then
vFiles = Split(OFN.sFile, Chr(0))

For lFile = 1 To UBound(vFiles) - 4 ' More than 1 file then do this until there are no more files
List1.AddItem vFiles(0) + "\" & vFiles(lFile)
List2.AddItem vFiles(lFile)
Next
If UBound(vFiles) = 4 Then
List1.AddItem OFN.sFile
List2.AddItem OFN.sFileTitle
End If
End If
End Sub


--------------------------------------
---------------------------------------
y en el modulo:


Public Const OFN_ALLOWMULTISELECT As Long = &H200
Public Const OFN_CREATEPROMPT As Long = &H2000
Public Const OFN_ENABLEHOOK As Long = &H20
Public Const OFN_ENABLETEMPLATE As Long = &H40
Public Const OFN_ENABLETEMPLATEHANDLE As Long = &H80
Public Const OFN_EXPLORER As Long = &H80000
Public Const OFN_EXTENSIONDIFFERENT As Long = &H400
Public Const OFN_FILEMUSTEXIST As Long = &H1000
Public Const OFN_HIDEREADONLY As Long = &H4
Public Const OFN_LONGNAMES As Long = &H200000
Public Const OFN_NOCHANGEDIR As Long = &H8
Public Const OFN_NODEREFERENCELINKS As Long = &H100000
Public Const OFN_NOLONGNAMES As Long = &H40000
Public Const OFN_NONETWORKBUTTON As Long = &H20000
Public Const OFN_NOREADONLYRETURN As Long = &H8000& 'see comments
Public Const OFN_NOTESTFILECREATE As Long = &H10000
Public Const OFN_NOVALIDATE As Long = &H100
Public Const OFN_OVERWRITEPROMPT As Long = &H2
Public Const OFN_PATHMUSTEXIST As Long = &H800
Public Const OFN_READONLY As Long = &H1
Public Const OFN_SHAREAWARE As Long = &H4000
Public Const OFN_SHAREFALLTHROUGH As Long = 2
Public Const OFN_SHAREWARN As Long = 0
Public Const OFN_SHARENOWARN As Long = 1
Public Const OFN_SHOWHELP As Long = &H10
Public Const OFS_MAXPATHNAME As Long = 260

'OFS_FILE_OPEN_FLAGS and OFS_FILE_SAVE_FLAGS below
'are mine to save long statements; they're not
'a standard Win32 type.
Public Const OFS_FILE_OPEN_FLAGS = OFN_EXPLORER _
Or OFN_LONGNAMES _
Or OFN_CREATEPROMPT _
Or OFN_NODEREFERENCELINKS

Public Const OFS_FILE_SAVE_FLAGS = OFN_EXPLORER _
Or OFN_LONGNAMES _
Or OFN_OVERWRITEPROMPT _
Or OFN_HIDEREADONLY

Public Type OPENFILENAME
nStructSize As Long
hWndOwner As Long
hInstance As Long
sFilter As String
sCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
sFile As String
nMaxFile As Long
sFileTitle As String
nMaxTitle As Long
sInitialDir As String
sDialogTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
sDefFileExt As String
nCustData As Long
fnHook As Long
sTemplateName As String
End Type

Public OFN As OPENFILENAME

Public Declare Function GetOpenFileName Lib "comdlg32" _
Alias "GetOpenFileNameA" _
(pOpenfilename As OPENFILENAME) As Long

Public Declare Function GetSaveFileName Lib "comdlg32" _
Alias "GetSaveFileNameA" _
(pOpenfilename As OPENFILENAME) As Long

Public Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" _
(ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
  #4 (permalink)  
Antiguo 24/11/2005, 21:30
Avatar de satake  
Fecha de Ingreso: julio-2004
Mensajes: 140
Antigüedad: 19 años, 9 meses
Puntos: 0
split y visual 5

no me funciona la funcion split, me imagino que será porque uso visual 5.0, como puedo hacer para usar esta funcion?. gracias por el codigo, espero puedan ayudarme, lo demas todo bien.
__________________
:aplauso: www.aponlinevillaguay.com.ar :aplauso:

Cita:
Iniciado por alguien
El arca de Noé fue hecha por principiantes, el Titanic por "profesionales".
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:29.