Link to home
Start Free TrialLog in
Avatar of Heyitsjoe80
Heyitsjoe80

asked on

Searching a File Tree

I have a program running off a CD that creates a File Tree with all the directories on the CD. There are 3 CD's in all.  There are sub-directories that are numbered with 8 digits.  For example, 60003451 or 70003459.  These sub-directories are in all different areas in the File Tree.  Is there a way to create a control that can search for the 8-digit number and take the user to that subdirectory.  All I need is a text box and a button control.  Nothing fancy at all.  Also, if the 8-digit number that the user types in is incorrect, tell the user it's a wrong number or on another CD.  Thanks!
Avatar of ElrondCT
ElrondCT
Flag of United States of America image

Maybe I'm not knowledgeable enough about VB .NET, but I'm not sure quite what type of data structure you're describing with a "File Tree." I don't see that term used in the online help for either VB 2003 or VB 2005. What type of data structure is holding the information? Do you mean a TreeView?

If so, I'm not aware of a built-in search command for a TreeView control. You'd have to write your own looping command using a For Each ... Next to go through each node of the control, looking for a match. If you put the entire path in the Tag property for the node, you could then return the tag and move to that directory if the match is made.

If I'm pointing in the right direction but you're not sure how to handle the details, let me know and I can flesh it out. If I'm all wet, please give us a better sense of how the directory list is structured, and we can take it from there.
ASKER CERTIFIED SOLUTION
Avatar of vb_jonas
vb_jonas
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry the commented line should be:

get files in a similar way: My.Computer.FileSystem.GetFiles(StartPath, FileIO.SearchOption.SearchAllSubDirectories, Me.TextBox1.Text))

and you can search with wildcards (*.txt) but you dont need that do you. :-)
My... requires DotNet2 btw (VS 2005)