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 8556435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:21:01+00:00 2026-06-11T15:21:01+00:00

I have the struct: public struct BaseFile { public string FileName; public string Path;

  • 0

I have the struct:

public struct BaseFile
{
    public string FileName;
    public string Path; // this is not the full path. it is the fullPath of it's parent directory in other words.
}

and I have the class

 public class MyFileDir // can be a file or directory
 {
      public string Name;
      public string FullPath;
      public List<MyFileDir> Children;
      public bool IsDirectory;
      // many more other properties
 }

So I have one thread place files on LinkedList<BaseFile> myLinkedList and I will like another thread to start casting those files too MyFileDir root (note I used linkedList instead of list because the addresses of linkedList does not change where a List changes its address every time it needs to grow)

I have a bool variable IsRunning that will let me know if the other thread is still adding base files to the linked list. So I have something like:

        var curNode = myLinkedList.First;

        while (IsRunning)
        {
            if (curNode.Next == null) // wait until next node is not null
            {
                Thread.Sleep(100);
                continue;
            }

            curNode = curNode.Next;
            AddItemToTree(curNode.Value);
        }

so as you can see I am having trouble implementing the method AddItemToTree I basically will like to start building the tree in that method. So first I will look at the root and search the directory where I should add curNode.Value. I am having a hard time doing that.

  • 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. Editorial Team
    Editorial Team
    2026-06-11T15:21:02+00:00Added an answer on June 11, 2026 at 3:21 pm
         MyFileDir root = new MyFileDir(); //root Node
    

    &

         var curNode = myLinkedList.First;
    
        while (IsRunning)
        {
            if (curNode.Next == null) // wait until next node is not null
            {
                Thread.Sleep(100);
                continue;
            }
    
            curNode = curNode.Next;
            curFileDir = new MyFileDir(curNode);// your cast here
    
    
        List<string> mylist = curFileDir.FullPath.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries).ToList(); // this gives a list of dirs in FullPath to explore
    
    
    
            MyFileDir temp = root;
            foreach (string filedirName in mylist)
            {
                temp = AddNode(temp, filedirName );
            }
    
    
      }
    

    the first loop means if the node exists return it, else create it & return it

           private MyFileDir AddNode(MyFileDir parent, string filedirName)
    {
        foreach (MyFileDir subfiledir in parent.Children)
            if (subfiledir.Name == header)
                return subfiledir;
    
        MyFileDir filedir = new MyFileDir(fileName);
        parent.Children.Add(fileName);
        return fileName;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a struct like this: public struct MyStruct { public string Name; public
I have a struct containing song data: public struct uLib { public string Path;
I have a struct like this: public struct Vehicles { public string Name {
So I have this struct: public struct PurchaseOrderStatus { public const string Open =
I have a struct that looks something like this: [StructLayout(LayoutKind.Sequential)] public struct in_addr {
Say I have a struct like so public struct MyStruct { string StructConfig {
I have a class class PCB { public: struct { string type; **linklist list;**//refer
I have this code (C#): using System.Collections.Generic; namespace ConsoleApplication1 { public struct Thing {
I have a struct like this: public struct stuff { public int ID; public
I have a class defined like this: public class StateMachineMetadata<T> where T: struct {

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.