|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DirectoryInfo.GetFiles -> from all subfoldersI have folder Music with subfolder Rock with subfolder Kult folder tree looks like this: Music -Rock -Kult and in folders called Kult and Rock I have txt files. Do you have code, with directoryinfo, which can show names of all files?? from first subfolder called Rock and from second called Kult? I found loops by which i can display files from first subfolder Rock but files in Kult isn't shown. Sorry for my english, but you know... still learning Thx Mrozu You have to use recursive loops, where you're calling the function, from
the function itself. e.g: Public Function FindFiles(ByVal Path As String) As Boolean Dim Directories As New IO.DirectoryInfo(Path) Dim Directory As IO.DirectoryInfo For Each Directory In Directories.GetDirectories ListBox1.Items.Add(Directory.Name) If Directory.GetDirectories.Length > 0 Then FindFiles(Directory.FullName) End If Next End Function Should work, but not tested :) - Tank Mrozu wrote: Show quoteHide quote > i forgot. VB.NET 2003 > > Mrozu > great but it displaies only folders'es names. but how rebuild it for
files'es names in those folders? Thx Mrozu The recusive function will need to provide the filenames first with the
GetFiles method feeding a For Each loop to an instance of the FileInfo class. Easy, you could do this:
Public Function FindFiles(ByVal Path As String) As Boolean Dim Directories As New IO.DirectoryInfo(Path) Dim Directory As IO.DirectoryInfo Dim File As IO.FileInfo For Each Directory In Directories.GetDirectories For Each File In Directory.GetFiles ListBox1.Items.Add(File.Name) Next If Directory.GetDirectories.Length > 0 Then FindFiles(Directory.FullName) End If Next End Function - Tank Mrozu wrote: Show quoteHide quote > great but it displaies only folders'es names. but how rebuild it for > files'es names in those folders? > > Thx Mrozu >
How does child class access parent's variables
For each and form controls VB command line compiler vbc.exe AND type "Int32" is not defined How to use VB.Net user controls with in VB.6 Simple installation of vb.net apps.... Q: labels DLL and form updating problem Can't read xml to Excel (dataset.WriteXml) Multiline DataGrid cell? SqlExpress2005, VB.NET and Crystal Reports |
|||||||||||||||||||||||