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

  • Home
  • SEARCH
  • 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 8434523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:40:47+00:00 2026-06-10T06:40:47+00:00

My TreeView control is displaying the structure of some selected hard disk drive. In

  • 0

My TreeView control is displaying the structure of some selected hard disk drive. In my addToParentNode, I make a call from after the tree view is expanded. But when I pass the node from one method to another, an “Object reference not set to an instance of an object” exception is thrown.

void addToParentNode(TreeNode childNodes)
{
    DirectoryInfo getDir = new DirectoryInfo(childNodes.Tag.ToString());
    DirectoryInfo[] dirList = getDir.GetDirectories();
    foreach (DirectoryInfo dir in dirList)
    {
        TreeNode parentNode = new TreeNode();
        parentNode.Text = dir.Name;
        parentNode.Tag = dir.FullName;
        childNodes.Nodes.Add(parentNode);
    }
}

private void tv_fileExplore_AfterExpand(object sender, TreeViewEventArgs e)
{
    foreach (TreeNode item in e.Node.Nodes)
    {
        addToParentNode(item);
    }
}

Can someone point me in the right direction?

  • 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-10T06:40:48+00:00Added an answer on June 10, 2026 at 6:40 am

    According to the comments on your question, the Tag property of a tree node is null.

    You are assigning a non-null value to every tree node in your addToParentNode method, but somewhere, there must be a start and you must be creating a root node. Therefore, that root node apparently has its Tag property still set to null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TreeView control in a Windows Forms application that is displaying my
I have TreeView control and I want to bind tree nodes' IsExpanded property to
I have a page that uses a TreeView control from ComponentArt. If I add
I am trying to create a TreeView from the Silverlight TreeView control. I have
I need populate a TreeView control to display Hierarchy Data from a DataBase. The
I need some advice regarding conversion of an AJAX TreeView control to a LinkButton
I've got a treeview control, and have caught its after-label-edit event. I want to
I have a treeview control on an aspx page. The data comes from database
I have a treeview control in my web application. I build this tree view
I have a TreeView control, and after a new node is added, I need

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.