Computing.Net > Forums > Programming > vb.net enumerate files from folder

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

vb.net enumerate files from folder

Reply to Message Icon

Name: jamesc
Date: September 21, 2006 at 04:15:39 Pacific
OS: n/a
CPU/Ram: n/a
Product: n/a
Comment:

Hey guys,

Im using vb.net, im trying to enumerate all files (only files) from a folder and any sub folders it may have. I want this to happen one by one. I have found many different ways of doing this, but i cant gte it to enumerate from sub folders as well. Also, id prefer it if only the actual filename and extension was shown instead of the full path to each file. Any help is appreciated.

To be fair, ive got it it almost working, i just cant get it enumerating files from subfolders within c:\test, here is what i have.

Dim Directory As New IO.DirectoryInfo("c:\test")
Dim allFiles As IO.FileInfo() = Directory.GetFiles("*.*")
Dim singleFile As IO.FileInfo


For Each singleFile In allFiles

MsgBox(singleFile.Name)

Next

James



Sponsored Link
Ads by Google

Response Number 1
Name: jamesc
Date: September 21, 2006 at 06:20:14 Pacific
Reply:

Never mind guys, worked it out, had to change a line:

Dim allFiles As IO.FileInfo() = Directory.GetFiles("*.*", SearchOption.AllDirectories)


0

Response Number 2
Name: jhunt303
Date: September 21, 2006 at 06:23:01 Pacific
Reply:

Ok, there is a really subtle OOP way to do this,

FUCNTION YourListDirFunc("C:\")
call YourListDirFunc(Results)

This will recurse all the directories


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: vb.net enumerate files from folder

copy files from folder A to folder B .... www.computing.net/answers/programming/copy-files-from-folder-a-to-folder-b-/20177.html

VB.NET Open files and Create Email www.computing.net/answers/programming/vbnet-open-files-and-create-email/3125.html

Vb .net saving file www.computing.net/answers/programming/vb-net-saving-file/12084.html