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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:20:03+00:00 2026-06-09T14:20:03+00:00

I have a parent folder that contains inside it multiple folders named Project-* (folders

  • 0

I have a parent folder that contains inside it multiple folders named Project-* (folders are numbered so Project-1, Project-15, Project-253 etc). Inside of each of those folders is a zip file, always the same name ‘project.zip’. This means that when the folder structure is correct it should ALWAYS be TopFolder\Project-*\project.zip.

I am trying to write a program that looks at each Project-* folder to see if the project.zip file is nested inside another folder (example: Project-*\newfolder\project.zip)

I have some code that looks for folders called Project-* and lists them if they have subdirectories, but it seems to consider my project.zip files as folders so it is showing EVERYthing as having subdirectories.

 DirectoryInfo directory = new DirectoryInfo(txtbxOldFolder.Text);
            DirectoryInfo[] folders = directory.GetDirectories("*Project-*", SearchOption.AllDirectories);


            //finds folders nested in the folder
            var query = from folder in folders
                        where folder.GetFileSystemInfos().Length > 0 
                        select folder.FullName.ToString();
            foreach (string str in query)
            {
                //this adds the path of any Project-* folder with subdirectories
                listNestedFolder.Add(str);
            }

As mentioned the above code does find any Project-* folder with subdirectories, however it also finds any that are Project-*\project.zip. How can I get it to stop identifying the zip file as a directory?

  • 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-09T14:20:06+00:00Added an answer on June 9, 2026 at 2:20 pm

    GetFileSystemInfos() returns both files and folders.
    You probably want to call GetDirectories().

    For better performance, you can write where folder.EnumerateDirectories().Any()

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

Sidebar

Related Questions

I have a parent folder called myfiles which contains several children folders. Each of
I have a folder structure that contains multiple javascript files, each of these files
I have a parent project that is branched to many dependent child projects. I
I have a parent-/child relationship of folders, which looks like this: A folder can
I have this script that does only the parent folder, it does not rename
I have stored procedure that returns results sorted dynamically. The parent folder (this is
I have two different folders located not under the same parent folder. Is it
I have a basic website nav layout that looks like this: <li class=folder parent_folder>
I have a parent div .photo_container that holds an img , and stretches to
I have a parent class which contains a child object. I am using set

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.