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

files in folders

P: n/a
tim
Hi all!
How to create array of string, which contains names of all files with full
path in special folder (e.g. c:\windows). In this folder it may be
subfolders of various levels.

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Did you try Directory.GetFiles()?

For e.g. Directory.GetFiles (@"C:\Windows") gets you the list of files with
full path as a string array.

HTH

"tim" <ti******@mail.ru> wrote in message
news:O3**************@TK2MSFTNGP09.phx.gbl...
Hi all!
How to create array of string, which contains names of all files with full
path in special folder (e.g. c:\windows). In this folder it may be
subfolders of various levels.


Nov 21 '05 #2

P: n/a
tim
.... but only for root of c:\windows\
what about all subfolders?

"Shiva" <sh******@online.excite.com> wrote in message
news:uD**************@TK2MSFTNGP14.phx.gbl...
Did you try Directory.GetFiles()?

For e.g. Directory.GetFiles (@"C:\Windows") gets you the list of files with full path as a string array.

HTH

Nov 21 '05 #3

P: n/a
tim
oh, I'm find in MSDN, thanks for suggestion:

' Process all files in the directory passed in, recurse on any directories
' that are found, and process the files they contain.

Public Shared Sub ProcessDirectory(ByVal targetDirectory As String)
Dim fileEntries As String() = Directory.GetFiles(targetDirectory)
' Process the list of files found in the directory.
Dim fileName As String
For Each fileName In fileEntries
ProcessFile(fileName)

Next fileName
Dim subdirectoryEntries As String() =
Directory.GetDirectories(targetDirectory)
' Recurse into subdirectories of this directory.
Dim subdirectory As String
For Each subdirectory In subdirectoryEntries
ProcessDirectory(subdirectory)
Next subdirectory

End Sub 'ProcessDirectory

' Insert logic for processing found files here.
Public Shared Sub ProcessFile(ByVal path As String)
Console.WriteLine("Processed file '{0}'.", path)
End Sub 'ProcessFile
End Class 'RecursiveFileProcessor

"Shiva" <sh******@online.excite.com> wrote in message
news:uD**************@TK2MSFTNGP14.phx.gbl...
Did you try Directory.GetFiles()?

For e.g. Directory.GetFiles (@"C:\Windows") gets you the list of files with full path as a string array.

HTH

Nov 21 '05 #4

P: n/a
tim schrieb:
How to create array of string, which contains names of all files with full
path in special folder (e.g. c:\windows). In this folder it may be
subfolders of various levels.


FileSystemEnumerator
<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/FileSystemEnumerator.zip>

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

This discussion thread is closed

Replies have been disabled for this discussion.