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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:41:08+00:00 2026-06-04T00:41:08+00:00

I have a function that is recursive in C# that i want to edit

  • 0

I have a function that is recursive in C# that i want to edit a global variable(i assume it is global due to the public before it) declared outside the function. For some reason that i do not know it cannot see the public variable within that specific function. It can see it in the first function in my code, but not in the second where i need to access it and change it to save a LOT of time opening a LOT of files…

Is there any reason why it wouldnt be accessable? and if so, how can i either get around it?

Thanks so much in advance!

public int[] timeInfo = new int[2];
   private void ListDirectory(TreeView treeView, string path) 
        {     
            treeView.Nodes.Clear();   
            var rootDirectoryInfo = new DirectoryInfo(path);    
            treeView.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo)); 
        }

   private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo) 

   {

       var directoryNode = new TreeNode(directoryInfo.Name);

       foreach (var directory in directoryInfo.GetDirectories())
            directoryNode.Nodes.Add(CreateDirectoryNode(directory));

       foreach (var file in directoryInfo.GetFiles())            
       {

           int check =0;                         
           try                
           {

               string s = "";                    
               s = directoryInfo.FullName + "\\" + file.Name;                    
               List<string> row, row2, row3 = new List<string>();

               using (StreamReader readFile = new StreamReader(s))
               {

                   row = (readFile.ReadLine().Split(',').ToList());
                   try 
                   {                           
                       row2 = (readFile.ReadLine().Split(',').ToList());
                       //timeInfo[0] = row2[0];
                   }
                   catch { check = 1; }
                   try
                   {
                       row3 = (readFile.ReadLine().Split(',').ToList());
                       //timeInfo[1] = row3[0];
                   }

                   catch { }
                }

                TreeNode[] headerNodes = new TreeNode[row.Count];

                for (int i = 0; i < row.Count; i++)
                {

                    headerNodes[i] = new TreeNode(row[i]);
                    if (check == 1)
                    {                       
                        headerNodes[i].BackColor = Color.Red;
                        headerNodes[i].ForeColor = Color.White;
                    }

                }
                directoryNode.Nodes.Add(new TreeNode(file.Name, headerNodes));
            }
            catch 
            {
                directoryNode.Nodes.Add(new TreeNode(file.Name));
            }
        }         
        return directoryNode; 
    }     
  • 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-04T00:41:10+00:00Added an answer on June 4, 2026 at 12:41 am

    The second function is static, and the variable exists only in the context of an object.

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

Sidebar

Related Questions

I have a recursion function that parses an object/array with a global variable. If
Say I have a recursive function that I want to know how many times
So if I have a recursive function with a global variable var_: int var_;
I have a function that is recursively calling itself, and i want to detect
Lets say I have a recursive function that creates lists within lists. It return
Is it possible to have a PHP function that is both recursive and anonymous?
I have a simple recursive function RCompare() that calls a more complex function Compare()
I have a function that I want to execute several times for different DOM
I have a recursive function (in C#) that I need to call about 800
I have a multi-thread C# application that uses some recursive functions in a dll.

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.