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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:35:40+00:00 2026-06-18T07:35:40+00:00

I am looking for a built-in functionality in .NET to query folders with relative

  • 0

I am looking for a built-in functionality in .NET to query folders with relative paths and wildcards, similar to Powershell’s dir command (also known as ls). As far as I remember, Powershell returns an array of DirectoryInfo and FileInfo .NET objects, which can later be used for processing. Example input:

..\bin\Release\XmlConfig\*.xml

would translate into several FileInfo‘s of XML files.

Is there anything like that in .NET?

  • 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-18T07:35:42+00:00Added an answer on June 18, 2026 at 7:35 am

    System.IO.Directory is the static class that provides that functionality.

    For instance your example would be:

    using System.IO;
    
    bool searchSubfolders = false;
    foreach (var filePath in Directory.EnumerateFiles(@"..\bin\Release\XmlConfig",
                                                      "*.xml", searchSubfolders))
    {
        var fileInfo = new FileInfo(filePath); //If you prefer
        //Do something with filePath
    }
    

    A more complex example would be: (note this isn’t really tested very thoroughly, for instance ending a string with \ would cause it to error)

    var searchPath = @"c:\appname\bla????\*.png";
    //Get the first search character
    var firstSearchIndex = searchPath.IndexOfAny(new[] {'?', '*'});
    if (firstSearchIndex == -1) firstSearchIndex = searchPath.Length;
    //Get the clean part of the path
    var cleanEnd = searchPath.LastIndexOf('\\', firstSearchIndex);
    var cleanPath = searchPath.Substring(0, cleanEnd);
    //Get the dirty parts of the path
    var splitDirty = searchPath.Substring(cleanEnd + 1).Split('\\');
    
    //You now have an array of search parts, all but the last should be ran with Directory.EnumerateDirectories.
    //The last with Directory.EnumerateFiles
    //I will leave that as an exercise for the reader.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for some Rails/Facebook functionality that has already been built - as a
Is there any built in functionality to MIME a file in C# .Net? What
I'm looking at transferring existing functionality (built with PrototypeJS) to jQuery and have been
I often make small websites and use the built in ASP.NET membership functionality in
I am looking for a built-in Ruby method that has the same functionality as
I've started looking at jQuery's built-in tabs functionality here: http://docs.jquery.com/UI/Tabs Is there any way
I'm looking for a Java built-in data structure that would be the best at
I am looking for alternatives to the Eclipse built-in Java code formatter. Not stand-alone,
I'm looking at upgrading a POS (Point Of Sale) project which is currently built
I'm looking for a lightweight, no bells and whistles framework built in JAVA for

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.