Click to See Complete Forum and Search --> : in Treeview show parentFolders as roots and folder and files as parents and leafs


Sava
05-31-2006, 01:07 PM
I want to display the following structure in my TreeviewControl and right now I only return the files and folders under the root, but not the root itself.Can anyone offer some help please.

Here is the structure that I would like to see
Folder 1
folderA
folderB
Folder 2
folderA
folderB
Folder 3
folderA
folderB


I also need to filter the folders(A,B) to only return when they correspond to a project number.
Right now my paths are as follows
server/folder/Folder 1
server/folder/ Folder 2
server/folder/ Folder 3

I return right now all the files and folders inside of the above, but not the rootdirectory itself.
so my tree looks like this
folderA
---
---
folderB
---
---
folderA
----
etc

Here is my code:

Public Function Selection() As IHierarchicalEnumerable

Dim i As Integer
Dim rootPath As String
Dim fshe As New FileSystemHierarchicalEnumerable()
Dim rootDirectory As DirectoryInfo

For i = 1 To 3 Step 1
rootPath = GetPath(i) this is where I get the path I described above
IO.Directory.SetCurrentDirectory(rootPath)

rootDirectory = New DirectoryInfo(rootPath)

Dim fsi As FileSystemInfo
For Each fsi In rootDirectory.GetFileSystemInfos()
fshe.Add(New FileSystemHierarchyData(fsi))
Next fsi

Next

Return fshe
End Function 'Select