DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2005
    Posts
    47

    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

  2. #2
    Join Date
    Dec 2004
    Posts
    163
    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

  3. #3
    Join Date
    Apr 2005
    Posts
    47
    thank you it worked perfect

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links