NevSoFly
asked on
How to display in a treeview Folders, Subfolder and Files from a List(of String) collection.
I have a collection (List(of String)) that contains file paths. Some of these files are in the root folder and others are in subfolders. I want to display the paths in a treeview while keeping the hierarchy of the file structure. For example:
c:\testfile1
c:\Folder1\testfile2
c:\Folder1\subfolder1\test file3
c:\Folder2\testfile4
c:\Folder3\subfolder1\test file5
Should be displayed in the treeview as:
testFile1
Folder1
|_______testfile2
|_______subfolder1
|________testfile3
Folder2
|_______testfile4
Folder3
|_______subfolder1
|________testfile5
I hope this makes sense. Thank you for any and all help.
c:\testfile1
c:\Folder1\testfile2
c:\Folder1\subfolder1\test
c:\Folder2\testfile4
c:\Folder3\subfolder1\test
Should be displayed in the treeview as:
testFile1
Folder1
|_______testfile2
|_______subfolder1
|________testfile3
Folder2
|_______testfile4
Folder3
|_______subfolder1
|________testfile5
I hope this makes sense. Thank you for any and all help.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I'm not sure what you mean.
Do you mean only display folders/files that are at least one level 'up' from the root directory?
e.g. something like this.
testfile2
subfolder1
|________testfile3
testfile4
subfolder1
|________testfile5
Do you mean only display folders/files that are at least one level 'up' from the root directory?
e.g. something like this.
testfile2
subfolder1
|________testfile3
testfile4
subfolder1
|________testfile5
ASKER
I mean if the root directory is:
C:\somefolder\someotherfolder\folder1 (folder1 being the root directory).
That you only display the files and subfolders contained in folder1.
somefile.txt
subfolder1
|_______testfile2.txt
|_______subfolder1
|________testfile3.doc
subfolder2
|_______testfile4.xlsx
subfolder3
|_______subfolder1
|________testfile5.pdf
I basically don't want the user to have to click thru a ton of directories in order to get to the root directory.
C:\somefolder\someotherfolder\folder1 (folder1 being the root directory).
That you only display the files and subfolders contained in folder1.
somefile.txt
subfolder1
|_______testfile2.txt
|_______subfolder1
|________testfile3.doc
subfolder2
|_______testfile4.xlsx
subfolder3
|_______subfolder1
|________testfile5.pdf
I basically don't want the user to have to click thru a ton of directories in order to get to the root directory.
ASKER
Follow up question. If I wanted to leave out the top parent node 'C:\' and only have its child nodes displayed in the treeview, How would you do that?