Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a treeview, and I want to be able to get all the files inside a folder after I click a file inside that folder.
I am using this code:
//I am getting path has an ilegal form in the next line
//I also tried this statement inside the foreach, but with no luck
(Path.GetFullPath(Path.GetFileName(trwFileExplorer.SelectedNode.Name))))
//This was the other thing I tried

path.Text = Path.GetDirectoryName(trwFileExplorer.SelectedNode.Name);
//and I am getting the same error here inside the foreach            
            foreach (string file in Directory.GetFiles(path.Text))
                {
                    media = player.newMedia(Path.GetFullPath(Path.GetFileName(file.ToString())));
                    playlist.appendItem(media);
                    //path.Text = Path.GetFullPath(Path.GetFileName(file.ToString()));
                }


How can I fix this?
Thanks!
Posted

1 solution

Debug and check what is the value you get as trwFileExplorer.SelectedNode.Name in runtime. Are you sure that you want treeview Name property? it should be Text or Value depending on how you bind data and your requirements.
 
Share this answer
 
Comments
Member 10850253 21-Sep-15 14:18pm    
I changed it to this:

DirectoryInfo dir = new DirectoryInfo(Path.GetFullPath(Path.GetFileName(list.SelectedNode.Text)));

But I am still getting the error.
How can I fix this?
Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900