Resumen Funciones basadas en el FileSystemObjects

Mensaje enviado por "Marcos MASULLO" <mmasullo@microsystem.com.ar>

La clase FileSystemObjects ofrece varias facilidades para acceso al filesystem.
Public fso As New Scripting.FileSystemObject ' REFERENCES: Microsoft Scripting RunTime

Sin embargo, no todas las necesidades están resueltas en esa clase (ej. Utilización de wilcards para identificar "grupos" de archivos, etc). Podés preveer la complementación de fso con funciones tuyas o usar fso en tu implementación de algo más completo.

Las funciones siguientes (DirInfo) te pueden guiar un poco hacia lo que solicitás:


1) Public Function DirInfo(ByVal pFolderPath As String, _
                        ByVal pbFilesCount As Boolean, _
                        ByVal pbSize As Boolean) As String
Const CSEP = ", "

DirInfo = pFolderPath & CSEP & _
          IIf(pbFilesCount, Format(CantidadArchivos(pFolderPath), " ##,##0 Archivos"), "") & CSEP & _
          IIf(pbSize, Format(fso.GetFolder(pFolderPath).Size / 1000, " ###,###,##0 KB"), "")

End Function

2) Public Function CantidadArchivos(ByVal pCarpeta As String, _
                                Optional ByVal pExtensionArchivos As String) As String
On Error Resume Next

Dim fsoCarpeta As Folder
Dim fsoFile As File
Dim iCantidad As Long

If Vacio(pExtensionArchivos) Then
    pExtensionArchivos = "*"
End If

iCantidad = 0
For Each fsoFile In fso.GetFolder(pCarpeta).Files
    If ucaset(NombreExtensionArchivo(fsoFile)) Like ucaset(pExtensionArchivos) Then
        iCantidad = iCantidad + 1
    End If
Next fsoFile
For Each fsoCarpeta In fso.GetFolder(pCarpeta).SubFolders
    iCantidad = iCantidad + _
                CantidadArchivos(fsoCarpeta.Path, pExtensionArchivos)
Next fsoCarpeta

CantidadArchivos = iCantidad

End Function

3) fso.GetFolder(pCarpeta).SubFolders.Count

4)Public Function EspacioDisponibleStr(ByVal pDrivePath As String) As String
Dim Drv As Drive
Dim sRecurso As String

Set Drv = fso.GetDrive(fso.GetDriveName(pDrivePath))
If Mid(pDrivePath, 2, 1) = ":" Then
    sRecurso = UCase(Left(pDrivePath, 2))
Else
    sRecurso = "\" & _
                PalabrasIesima(pDrivePath, 2, "\") & "\" & _
                PalabrasIesima(pDrivePath, 3, "\") & "\" & _
                PalabrasIesima(pDrivePath, 4, "\") & ": "
End If
EspacioDisponibleStr = "Espacio Disponible en " & sRecurso & " " & _
                        Round(Drv.AvailableSpace / 1000 / 1000, 2) & " MB"

End Function

Marcos
----- Mensaje original -----
De: Martín Suárez Viacava
Para: grupovb@egroups.com ; visualbasic-esp@egroups.com
Enviado: Jueves 5 de Octubre de 2000 23:50
Asunto: (VB-ESP) Tamaño y Cant. de Arch.

Buenos Días a todos.
La duda que se me presenta hoy es la siguiente:
Cómo puedo hacer para saber cuantos archivos hay en una carpeta y sus subcarpetas.
Cantidad de Archivos - Tamaño total y cantidad de subcarpetas, cómo lo muestra Windows en las Propiedades.

Muchas Gracias

Martín Suárez Viacava
martin_suarez_v@ciudad.com.ar
http://www.visualb6.com/



Resumen Resumen

Visual Basic Página de Visual Basic

Página principal Página principal

www.jrubi.com