Read files

  • Thread starter Thread starter Pascal
  • Start date Start date
P

Pascal

Hello everybody

I would like to get all files names in a specify folder but also in all
subfolders

How can I do that ?

Thanks

Pascal
 
Hi,

Use recursion (A subroutine that calls itself) to list all the
files including sub directories.


How to use
ListFiles(Environment.GetFolderPath(Environment.SpecialFolder.Personal))



The procedure



Private Sub ListFiles(ByVal strPath As String)

Dim di As System.IO.DirectoryInfo

Try

di = New System.IO.DirectoryInfo(strPath)

For Each fi As System.IO.FileInfo In di.GetFiles

Trace.WriteLine(fi.Name)

Next

For Each diSub As System.IO.DirectoryInfo In di.GetDirectories

ListFiles(diSub.FullName)

Next

Catch ex As Exception

Trace.WriteLine("An error has occured")

End Try

End Sub



Ken

--------------------------

Hello everybody

I would like to get all files names in a specify folder but also in all
subfolders

How can I do that ?

Thanks

Pascal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top