Click here to Skip to main content
15,896,527 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi

in a path suppose i have n number of file and folder i have to read the Specfic three folder suppase a,b,c and the content of this folder and load to three control with root node fixed as suppose T in c# winform application.
Posted
Comments
OriginalGriff 15-Jan-14 6:13am    
And?
What have you tried?
Where are you stuck?
rahuls1 15-Jan-14 6:14am    
not getting any idea..please help
BillWoodruff 15-Jan-14 8:52am    
Show an example of the Path(s) you are dealing with, and tell us what "load to three control with root node fixed as suppose T in c# winform" means. Does it mean you have three TreeViews, three Nodes in one TreeView ... or ... ?

 
Share this answer
 
Try this sample..

C#
string folderLocation1 = @"D:\OLD Projects\BEData\BEData\Scripts";
           string folderLocation2 = @"D:\OLD Projects\BEData\BEData\Styles\css";
           string folderLocation3 = @"D:\OLD Projects\BEData\BEData\Images";

           treeView1.Nodes.Add("scripts");
           TreeNode[] tn1 = new DirectoryInfo(folderLocation1).GetFiles().Select(k => new TreeNode() { Text = (k.Name) }).ToArray();
           treeView1.Nodes[0].Nodes.AddRange(tn1);

           TreeNode[] tn2 = new DirectoryInfo(folderLocation2).GetFiles().Select(k => new TreeNode() { Text = (k.Name) }).ToArray();
           treeView1.Nodes.Add("csss");
           treeView1.Nodes[1].Nodes.AddRange(tn2);

           TreeNode[] tn3 = new DirectoryInfo(folderLocation3).GetFiles().Select(k => new TreeNode() { Text = (k.Name) }).ToArray();
           treeView1.Nodes.Add("images");
           treeView1.Nodes[2].Nodes.AddRange(tn3);
 
Share this answer
 
Comments
rahuls1 15-Jan-14 8:13am    
but i have Dirtectory inside Directory and in that i have file for folder Location one that how to do..
Karthik_Mahalingam 15-Jan-14 8:15am    
consider my solution..
in scripts folder, you will be having sub folders .. you need the files under sub folders also ???
or wat ??
rahuls1 15-Jan-14 8:28am    
ya in first folder location i have sub folder also i need to add that subfolder under the folder and the files in side that sub folder to there corrosponding Sub folder should attacedh to tree Controll
Karthik_Mahalingam 15-Jan-14 8:32am    
along with my solution.
try with this also.. it will help you.. http://stackoverflow.com/questions/6239544/c-sharp-how-to-populate-treeview-with-file-system-directory-structure/6239644#6239644
Karthik_Mahalingam 15-Jan-14 8:33am    
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/DirectoryTreeHost.htm

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