i need help with this piece of code to get files from directory and populate them in treeview.
foreach (DirectoryInfo directory in directories)
{
TreeNode node = TreeView.Nodes[0].Nodes.Add(directory.Name);
node.ImageIndex = 1;
foreach (FileInfo file in directory.GetFiles())
{
if (file.Exists)
{
TreeNode nodes = TreeView.Nodes[0].Nodes(node.Index).Nodes.Add(file.Name);
nodes.ImageIndex = 2;
}
}
}
i get this error: An object reference is required for the non-static field, method, or property 'System.Windows.Forms.TreeView.Nodes.get'
i appreciate any kind of help thanks