Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 164381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:44:03+00:00 2026-05-11T11:44:03+00:00

Im working with file systems and I have a List<> of file objects that

  • 0

Im working with file systems and I have a List<> of file objects that have the file path as a property. Basically I need to create a treeview in .NET but im struggling to think of the best way to go about doing this as I need to create a tree structure from a list like:

C:/WINDOWS/Temp/ErrorLog.txt C:/Program Files/FileZilla/GPL.html C:/Documents and Settings/Administrator/ntuser.dat.LOG 

etc….

The list is not structured at all and I cant make any changes to the current object structure.

I’m working in C#.

Many thanks for all who contribute

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T11:44:03+00:00Added an answer on May 11, 2026 at 11:44 am

    If you wanted to stick with the strings something like this would work…

    TreeNode root = new TreeNode(); TreeNode node = root; treeView1.Nodes.Add(root);   foreach (string filePath in myList) // myList is your list of paths  {     node = root;     foreach (string pathBits in filePath.Split('/'))     {       node = AddNode(node, pathBits);     }  }   private TreeNode AddNode(TreeNode node, string key) {     if (node.Nodes.ContainsKey(key))     {         return node.Nodes[key];     }     else     {         return node.Nodes.Add(key, key);     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Windows Forms application that I'm working on, but I'm having trouble
I have a working file rename java tool, now I want to add an
I'm working on a file format that should be written and read in several
I am currently working with a file name and I need to get the
For my Operating Systems class I have an assignment due that is built onto
I have been working with a c# tutorial for beginners to create an address
I'm working on getting an image into a picturebox on asp.net from a list-box
I have been trying to get this android service working but I can not
I have a project I am working that will search all loaded assemblies for
Basically I have a program which, when it starts loads a list of files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.