Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET File I/O and Registry > How to list EVERY ITEM in a PATH/Directory??


Reply
 
Thread Tools Display Modes
  #1  
Old 10-27-2004, 04:41 AM
VBISCOOL VBISCOOL is offline
Regular
 
Join Date: Sep 2004
Posts: 87
Question How to list EVERY ITEM in a PATH/Directory??


Hello all,

Supposing I have a path e.g C:\Documents and Settings\jxe3Desktop\Various
and this was called LongPath

Using system.IO how can I get the program to get every item in this path and list it in, say a textbox or listview??

I've tried IO.directory.getfiles() but i can't do anything with it.

Any help much appreciated

Thanks
Reply With Quote
  #2  
Old 10-27-2004, 10:31 AM
VBISCOOL VBISCOOL is offline
Regular
 
Join Date: Sep 2004
Posts: 87
Default

Actually I would also be willing to use the FIle System object if this happens to be better than IO for this thing. Whatever works.

Bear in mind that i know the full path name but i don't know everything that's physically in the path because some items will filenames will have been truncated making them difficult to locate.

Thanks
Reply With Quote
  #3  
Old 10-27-2004, 08:30 PM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

Quote:
Originally Posted by VBISCOOL
Hello all,

Supposing I have a path e.g C:\Documents and Settings\jxe3Desktop\Various
and this was called LongPath

Using system.IO how can I get the program to get every item in this path and list it in, say a textbox or listview??

I've tried IO.directory.getfiles() but i can't do anything with it.

Any help much appreciated

Thanks
This is what I'd use........

Code:
    Dim FileDirList() As String = Directory.GetFiles(LongPath)
    For i As Integer = 0 To FileDirList.GetUpperBound(0)
    Debug.WriteLine(FileDirList(i)) 'Obviously change this to add to whatever control you want
    Next
Reply With Quote
  #4  
Old 10-28-2004, 03:53 AM
VBISCOOL VBISCOOL is offline
Regular
 
Join Date: Sep 2004
Posts: 87
Default

Man, I am in your debt.
Reply With Quote
  #5  
Old 10-28-2004, 06:32 AM
excaliber's Avatar
excaliber excaliber is offline
Senior Contributor

* Expert *
 
Join Date: Nov 2002
Location: Ohio, USA
Posts: 1,828
Default

If you want all the files and subdirectories under that directory as well, use a recursive or iterative search.

http://www.xtremevbtalk.com/showthread.php?t=158264
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->