Click here to Skip to main content
15,920,801 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I saw really many examples displaying exisiting folder structure with TreeView, but what I am trying to do is following ->

I have a standard folder structure in my C# WinForms with several folders and subfolders and a comboBox which display exisiting folders in my path.

The user should be able to choose a exisiting folder from my comboBox and just press a button to create every checked Item in my TreeView.

What I have tried:

This is my existing Code:
public Form1()
 {
     InitializeComponent();
     this.FormBorderStyle = FormBorderStyle.None;
     Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20));
     foreach (TreeNode tn in pathLorem.Nodes)
     {
         tn.Expand();
     }
     DirectoryInfo obj = new DirectoryInfo("F:\\");
     DirectoryInfo[] folders = obj.GetDirectories();
     loremDropDown.DataSource = folders;
 }
I don't beg for a finished code, I just need a tutorial or a exisiting StackOverflow post. I'm searching for 1 hour now.
Posted
Updated 7-Sep-22 8:44am

If I understand right, user selects a location from dropdown, checks nodes on tree view and clicks a button. This button click would create a directory structure within the location. Is that correct? If yes, you can may be try this approach:

0. Create a high level list of strings.
1. Handle AfterCheck event for the tree view.
2. In the event handler, add node.FullPath to the string list. On uncheck, remove.
3. On button click, create all directories inside the selected folder based on the string list.
 
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