Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

I want to work with treeview to show files and folders from a root folder.(exemple : Root).

The Root folder has an folders and files in it.

Thank you for all your help.
Posted
Updated 17-Apr-11 1:48am
v2
Comments
OriginalGriff 17-Apr-11 5:17am    
What have your tried?
Where are you stuck?
pankajupadhyay29 17-Apr-11 5:34am    
search on Google you will find a lot of such example.
Dalek Dave 17-Apr-11 7:49am    
Edited for Grammar, Syntax and Readability.

 
Share this answer
 
v2
Comments
Dalek Dave 17-Apr-11 7:49am    
Good Links.
Tarun.K.S 17-Apr-11 8:01am    
Thanks!
Tarun.K.S 17-Apr-11 9:36am    
Comment from OP :
thank you so much for all your helps
Prasanta_Prince 17-Apr-11 13:55pm    
Good links..
Sergey Alexandrovich Kryukov 17-Apr-11 16:28pm    
No, best links are yours, because working with big directory tree is not trivial, must be virtualized (wait a minute, do both works use virtualized approach). I'm so sorry there is not a virtual tree class.
--SA
 
Share this answer
 
Comments
Tarun.K.S 17-Apr-11 8:01am    
Best Links!
Tarun.K.S 17-Apr-11 9:35am    
Comment from OP :
thank you so much for all your helps
I am using this function which is a recursive loop, try it, it is simple.
C++
void AddNode(TreeNode node, DirectoryInfo di)
    {
        foreach (DirectoryInfo d in di.GetDirectories())
        {
            TreeNode FolderNode = new TreeNode(d.Name);
            FolderNode.SelectAction = TreeNodeSelectAction.Expand;
            node.ChildNodes.Add(FolderNode);
            foreach (FileInfo fi in d.GetFiles())
            {
                TreeNode FileNode = new TreeNode(fi.Name);
                FileNode.SelectAction = TreeNodeSelectAction.Select;
                string ftpPath = fi.FullName.Replace(@"\\o7r38-5m0\r3d10f9er25h$\", @"ftp://192.168.2.128/Archive/");
                ftpPath = ftpPath.Replace(@"\", @"/");
                FileNode.NavigateUrl = "JavaScript:ope('"+ftpPath+"')";
                FolderNode.ChildNodes.Add(FileNode);
            }
            AddNode(FolderNode, d);
        }
    }

Thanks
 
Share this answer
 
Comments
Dalek Dave 17-Apr-11 7:49am    
Good Answer.
Tarun.K.S 17-Apr-11 9:36am    
Comment from OP :
thank you so much for all your helps
Prasanta_Prince 17-Apr-11 13:52pm    
Good Answer.. :)
Sergey Alexandrovich Kryukov 17-Apr-11 16:30pm    
This is pretty bad: you're trying to keep all data in tree view. For big directories, this is not realistic. Misleading approach.
--SA
Husain Ahmad Khalid 17-Apr-11 23:51pm    
Dear SAKryukov, I am trying to put all the data in tree view and that is my requirement, I just gave the above example to be used according to anyone's requirement, the importance is its recursive method not the data I am putting in tree view or nodes. still thanks for your comment.
 
Share this answer
 

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