Fallo en Función Dir con recursividad
Publicado por Carlos (1 intervención) el 21/01/2008 17:42:57
Hola.
Estoy intentando hacer un catalogador de CD. Para ello estoy utilizando la función dir con recursividad. Pero al ejecutarlo me da un error en tiempo de ejecución. Quería saber si a vosotros también os pasa, o si hay algún error en el código. Aquí está:
Private Sub Command1_Click()
MyPath = "C:Open" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
'Debug.Print MyName ' Display entry only if it
Text1.Text = Text1.Text & " $ " & MyName
metRecursivo (MyPath & MyName)
End If ' it represents a directory.
Text1.Text = Text1.Text & " $ " & MyName
End If
MyName = Dir ' Get next entry.
Loop
End Sub
Private Sub metRecursivo(path)
mPath = path ' Set the path.
mName = Dir(mPath & "", vbDirectory) ' Retrieve the first entry.
Do While mName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If mName <> "." And mName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(mPath & "" & mName) And vbDirectory) = vbDirectory Then
'Debug.Print MyName ' Display entry only if it
Text1.Text = Text1.Text & " $ " & mName
metRecursivo (mPath)
End If ' it represents a directory.
Text1.Text = Text1.Text & " $ " & mName
End If
mName = Dir ' Get next entry.
Loop
End Sub
Estoy intentando hacer un catalogador de CD. Para ello estoy utilizando la función dir con recursividad. Pero al ejecutarlo me da un error en tiempo de ejecución. Quería saber si a vosotros también os pasa, o si hay algún error en el código. Aquí está:
Private Sub Command1_Click()
MyPath = "C:Open" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
'Debug.Print MyName ' Display entry only if it
Text1.Text = Text1.Text & " $ " & MyName
metRecursivo (MyPath & MyName)
End If ' it represents a directory.
Text1.Text = Text1.Text & " $ " & MyName
End If
MyName = Dir ' Get next entry.
Loop
End Sub
Private Sub metRecursivo(path)
mPath = path ' Set the path.
mName = Dir(mPath & "", vbDirectory) ' Retrieve the first entry.
Do While mName <> "" ' Start the loop.
' Ignore the current directory and the encompassing directory.
If mName <> "." And mName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(mPath & "" & mName) And vbDirectory) = vbDirectory Then
'Debug.Print MyName ' Display entry only if it
Text1.Text = Text1.Text & " $ " & mName
metRecursivo (mPath)
End If ' it represents a directory.
Text1.Text = Text1.Text & " $ " & mName
End If
mName = Dir ' Get next entry.
Loop
End Sub
Valora esta pregunta


0