-
folder, subfolders, and text files
Hi everyone ,
I copied one folder which contain some subfolders and after few layers of subfolders there are some text files that i want to parse. for example:
my main folder is: My_Main_folder then inside it there are My_sub_one, my_sub_some, ..... then again inside these subs could be more subs until some where there are some txt file at each sub
is there any easy approch to open My_Main_folder and all subs and just read txt files.
Appreciate your help
-
pantea,
Here is a sub that accepts a folder name and then displays any text files in that folder and in any subfolders of that folder:
Private Sub DisplayFiles(ByVal folder As String)
Dim di As New DirectoryInfo(folder)
Dim fi As FileInfo
For Each fi In di.GetFiles
If fi.Extension = ".txt" Then
MsgBox("File: " & fi.FullName)
End If
Next
Dim subDI As DirectoryInfo
For Each subDI In di.GetDirectories
DisplayFiles(di.FullName & "\" & subDI.Name)
Next
End Sub
Call the sub like this:
DisplayFiles("E:\Test Folder")
MsgBox("Done")
Kerry Moorman
-
thank you it worked perfect
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks