By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,702 Members | 1,496 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,702 IT Pros & Developers. It's quick & easy.

Read files

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

Use recursion (A subroutine that calls itself) to list all the
files including sub directories.
How to use
ListFiles(Environment.GetFolderPath(Environment.Sp ecialFolder.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

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

"Pascal" <b@jeol.fr> wrote in message
news:41**********************@news.free.fr...
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

Nov 21 '05 #2

P: n/a
"Pascal" <b@jeol.fr> schrieb:
I would like to get all files names in a specify folder but also in all
subfolders


<URL:http://dotnet.mvps.org/dotnet/sample...s/FileSystemEn
umerator.zip>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.