Mensaje enviado por "Marcos MASULLO" <mmasullo@microsystem.com.ar>
Tal vez te resulte de utilidad la función SelectMiddleFolder(pLeftPath, pRightPath) que permite determinar un path completo, dentro del cual está el archivo pRightPath, considerando desconocido un nivel intermedio de directorios.
Su uso es algo así como:
ArmarPathImagen = PathConcat(SelMiddleFolder(sPath, sFile), sFile)
? SelMiddleFolder("C:\Fotos\", "00003")
"C:\fotos\05\00003"
Public Function SelMiddleFolder(ByVal pLeftPath As String, _
ByVal pRightPath As String) As String
On Error Resume Next
Dim fsoCarpeta As Folder
Dim fsoCarpetas As Folders
Dim ifolder As Integer
Static aSubFolders() As String
Static LeftPath As String
If LeftPath <> pLeftPath Then
Set fsoCarpetas = fso.GetFolder(pLeftPath).SubFolders
ReDim aSubFolders(fsoCarpetas.Count)
ifolder = 0
For Each fsoCarpeta In fsoCarpetas
If Not Vacio(fsoCarpeta) Then
ifolder = ifolder + 1
aSubFolders(ifolder) = fsoCarpeta
End If
Next
LeftPath = pLeftPath
End If
SelMiddleFolder = pLeftPath
For ifolder = 1 To UBound(aSubFolders)
If FileExists(PathConcat(aSubFolders(ifolder), pRightPath)) Then
SelMiddleFolder = aSubFolders(ifolder)
Exit Function
End If
Next
End Function
fso es FileSystemObjects ' MicrosoftScriptingRuntime
Public Function FileExists(ByVal pFile As String) As Boolean
' FileExists = (Dir(pFile) <> "")
' Dir() Fallaba con UNC de servidores de otros dominios
' fso.FileExists() fallaba con willcards (123*, )
FileExists = true
If Not fsoTmp.FileExists(pFile) Then
If Not (Dir(pFile) <> "") Then
FileExists = False
End If
End If
End Function
-----------------------------------------------------------
De: César
Para: visualbasic-esp@egroups.com
Enviado: Domingo 5 de Noviembre de 2000 10:02
Asunto: (VB-ESP) Directorio
Hola, esta es la primera vez que me dirigo a este foro, con el fin de pedir ayuda:
Quiero ver en un image1 unas foto, dependiendo del nombre que tenga el textbox la foto se vera, pero el problema que tengo es que las fotos las tengo guardadas en varios directorios teniendo la siguiente ruta (C:\Fotos\ ? \) donde ? puede ser cualquier directorio del 00 al 99. Si el nombre del fichero que aparece en el textbox es 00003 ¿como puedo hacer que independientemente del nombre del directorio se visualice la foto?
Saludos, y gracias anticipadas.
Cesar Vaquero