Visual Basic - Fallo en Función Dir con recursividad

Life is soft - evento anual de software empresarial
 
Vista:

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
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Fallo en Función Dir con recursividad

Publicado por Yo (1 intervención) el 28/01/2008 17:47:50
Mira esto
http://vb.mvps.org/samples/project.asp?id=DirDrill
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar