folder, subfolders, and text files


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: folder, subfolders, and text files

  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

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center