public void PopulateTreeView(string directoryValue, TreeNode parentNode) { try { DirectoryInfo directory = new DirectoryInfo(directoryValue); foreach (DirectoryInfo d in directory.GetDirectories()) { // Create Node TreeNode t = new TreeNode(d.Name); PopulateTreeView(d.FullName, t); parentNode.Nodes.Add(t); } foreach (FileInfo f in directory.GetFiles("*.mp3")) { TreeNode t = new TreeNode(); t.Text = f.Name.ToString(); t.Tag = Path.GetFullPath(f.DirectoryName); parentNode.Nodes.Add(t); } } catch (UnauthorizedAccessException) { parentNode.Nodes.Add("Access denied"); } }
lbPlaylist.DisplayMember = tvMedia.SelectedNode.Text; lbPlaylist.ValueMember = Convert.ToString(tvMedia.SelectedNode.Tag);
lbPlaylist is the ListBox
can anyone of you help here ?
is ther i a better way ?
and please.. remember im a complete newbie :)