Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
TreeView1.Nodes.Clear()
ProcessDirectories("c:\path....", TreeView1.Nodes)
End Sub
Private Sub ProcessDirectories(ByVal path As String, ByVal parentCollection As TreeNodeCollection)
Dim items As String() = IO.Directory.GetDirectories(path)
Dim item As String
Dim itemNode As TreeNode
For Each item In items
itemNode = parentCollection.Add(item)
this is the recursion
ProcessDirectories(item, itemNode.Nodes)
Next
End Sub
public static string[]GetAllFiles(string Dir)
{
DirectoryInfo Di=new DirectoryInfo(Dir);
FileInfo[]FArr=Di.GetFiles();
for(int j=0; j<FArr.Length; j++)
{
o+=FArr[j].FullName+"\n";
}
string[]SubDirs=Directory.GetDirectories(Dir);
foreach(string D in SubDirs)
{
o+="1\n";
GetAllFiles(D);
}
char[]sp=new Char[]{\n};
string[]AllDirectories=o.Split(sp[0]);
o="";
return AllDirectories;
}