Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > .NET

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-24-2005, 04:01 PM
pantea pantea is offline
Registered User
 
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
Reply With Quote
  #2  
Old 05-24-2005, 04:20 PM
kmoorman kmoorman is offline
Registered User
 
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
Reply With Quote
  #3  
Old 05-24-2005, 04:36 PM
pantea pantea is offline
Registered User
 
Join Date: Apr 2005
Posts: 47
thank you it worked perfect
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:20 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.