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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:53:29+00:00 2026-06-15T15:53:29+00:00

I am having an issue with trying to make a list by searching through

  • 0

I am having an issue with trying to make a list by searching through a file structure. Was trying to make a basic c# console program that would just run and do this.

My structure is organize like the following.

My Network \
X1 \
Users \
(many many user folders) \
Search for a specific sub folder \
make a list in a text file of any folders within this sub folder

So i have to be able to search every user folder and then check for a folder (this will be the same every time) Then make a list of the found folders within that sub folder with the following format

username (name of the user folder) >> Name of folder within the specific folder.

its been a terribly long time since i have had to try anything with searching within a file structure so blanking on this terribly.

**************** EDIT!!!!!

Thanks for the info and links. Working on this now but wondering if this makes sense and would work. Don’t want to just test it before i make sure it looks like something that wouldn’t just screw up.

            TextWriter outputText = new StreamWriter(@"C:\FileList.txt", true);
        outputText.WriteLine("Starting scan through user folder");
        string path = @"\\X1\users";
        string subFolder = "^^ DO NOT USE - MY DOCS - BACKUP ^^";
        string [] user_folders = Directory.GetDirectories(path);

        foreach (var folder in user_folders)
        {
            string checkDirectory = folder + "\\" + subFolder;

            if (Directory.Exists(checkDirectory) == true)
            {
                string [] inner_folders = Directory.GetDirectories(checkDirectory);
                foreach (var folder2 in inner_folders)
                {
                    outputText.WriteLine(folder2);
                }
            }
        }
        outputText.WriteLine("Finishing scan through user folder");
        outputText.Close();

Fixed and working!!!! had to change the string [] lines, to make it .GetDirectories instead of .GetFiles!!

  • 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-15T15:53:31+00:00Added an answer on June 15, 2026 at 3:53 pm

    As Bali C mentioned, the Directory class will be your friend on this one. The following examples should get you started.

    From: http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/3ea19b83-b831-4f30-9377-bc1588b94d23/

    //Obviously you'll need to define the correct path.
    string path = @"My Network\X1\Users\(many many user folders)\Search for a specific sub folder \";
    
    // Will Retrieve count of all files in directry and sub directries
    int fileCount = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Length; 
    
    // Will Retrieve count of all files in directry but not sub directries
    int fileCount = Directory.GetFiles(path, "*.*", SearchOption.TopDirectory).Length; 
    
    // Will Retrieve count of files .txt extensions in directry and sub directries
    int fileCount = Directory.GetFiles(path, "*.txt", SearchOption.AllDirectories).Length; 
    

    If you need to search the /Users/ folder for certain people, or certain conditions you could do the following:

    string path = @"PATH_TO_USERS_DIRECTORY";
    string [] user_folders = Directory.GetFiles(path);
    foreach(var folder in user_folders)
    {
        if folder == "MyFolder";
            Process(folder);  //Search the directory here.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an issue trying to make a small text-fantasy type game involving
I am having a big issue trying to delete from an UITableView. Just for
Im having an issue when im trying to read in a text file while
I'm having an issue trying to make a client side validation on yii 1.1.12.
I am having some issues with an extension that i am trying to make.
I'm trying to make an NSMutableArray usable in multiple classes. I'm having an issue
I was having trouble with a voting system that I'm trying to make in
I am currently learning C, and am having some issues with trying to make
I am having an issue trying to deal with timezones in the JQuery date/time
I am having an issue with trying to retrieve the contents of the view

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.