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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:39:36+00:00 2026-06-05T08:39:36+00:00

What is the most efficient way to find all exe files on disk using

  • 0

What is the most efficient way to find all exe files on disk using C#?

It will be done in background thread in program so disk usage should be as small as possible.

  • 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-05T08:39:38+00:00Added an answer on June 5, 2026 at 8:39 am

    The link you provided is the most efficient way in C# (with .Net 4.0):
    Directory.EnumerateFiles Method

    Prior versions of .Net had to use a slower method that caused memory issues on large drives, @hatchet showed a great example: Is there a faster way to scan through a directory recursively in .NET?

    I wouldn’t suggest using the TPL as Jon Skeet mentions here:
    Task Parallel Library for directory traversal

    If you see the first comment in this MSDN link: Iterate File Directories with the Parallel Class I dont even think Microsoft had success with this TPL method either.

    The other suggestion I have is using LogParser and you can use it with C#! Its a free Microsoft product but I’m not sure about re-dist permissions, I had to include it in my package separately last time I used it. It full on flys, faster than a speeding train!

    As per @spender comment I found a Log Parser example that finds files dated 180 days and older, you could try it out and adapt it if its useful:

    SELECT
        ContentPath, [Days (Old)], FileName, [Creation Date Time]
        USING creationtime AS [Creation Date Time],
        TO_DATE([Creation Date Time]) AS Cdate,
        SUB(TO_LOCALTIME(SYSTEM_TIMESTAMP()), Cdate) AS Days,
        DIV(TO_INT(Days),86400) As [Days (Old)],
        EXTRACT_PATH(TO_LOWERCASE(path)) AS ContentPath,
        TO_LOWERCASE(name) AS FileName
    FROM %source% 
    WHERE
      (attributes NOT LIKE 'D%')
    AND
      ([Days (Old)] >= TO_INT('%day%'))
    ORDER BY [Creation Date Time] DESC
    

    %source% could be something like c:\*.exe as shown in the argument c:\temp\*.*. Save the above as cc.sql, run it with the following syntax:

     C:\Temp\Tools\Logparser>LogParser.exe file:cc.sql?source="c:\temp\*.*"+day="180"  -i:FS -preserveLastAccTime -rtp:-1
    

    EDIT

    Thanks for the upvotes guys! I made this Event Analyser app in 2005 (before .net 2.0 was released) and since the Log Parser suggestion was so popular I thought I’d share the way you can use LogParser in .Net

    The good folks over at http://visuallogparser.codeplex.com/ have
    provided us with the source code.

    Open the VisualLogParser solution in VS2010, ignore the prompt about debugging, after the solution loads, F5, set the combo-box to FS (FileSystem), paste in this query and press go.

    SELECT
        ContentPath, [Days (Old)], FileName, [Creation Date Time]
        USING creationtime AS [Creation Date Time],
        TO_DATE([Creation Date Time]) AS Cdate,
        SUB(TO_LOCALTIME(SYSTEM_TIMESTAMP()), Cdate) AS Days,
        DIV(TO_INT(Days),86400) As [Days (Old)],
        EXTRACT_PATH(TO_LOWERCASE(path)) AS ContentPath,
        TO_LOWERCASE(name) AS FileName
    FROM 'c:\*.exe' 
    WHERE
      (attributes NOT LIKE 'D%')
    AND
      ([Days (Old)] >= TO_INT('180'))
    ORDER BY [Creation Date Time] DESC
    

    At the same time you may wish run any other .Net application that searches directories and compare the results!!!

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

Sidebar

Related Questions

What's the most efficient way to find a list of all non-HTTPS URLs requested
I'm trying to find the most efficient way to get all objects from the
I'm trying to develop a genetic algorithm that will find the most efficient way
I need to find the most efficient way of matching multiple regular expressions on
I am interested to find out what is the best/fastest (most efficient) way to
What is the fastest / most efficient way of getting all the distinct items
What is the quickest most efficient way to search text for words using non-casesensitive
Trying to get data in the most efficient way possible for some reports, using
I need to find the most efficient way to insert a value into table
What is the most efficient way to get all of the external ip address

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.