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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:33:39+00:00 2026-05-31T12:33:39+00:00

I have a File Server which is mapped to a network drive letter W.

  • 0

I have a File Server which is mapped to a network drive letter W. it has 732 main folders and sub folders and a lot of files. I have mapped a virtual Directory to this drive and named it “Documents”.

Now I want to check how much time it takes to find only the folders which contains “final” in it. i created a Console app not a web app yet and write below code which gave me results very very slow which is not desired. Please find below the code

DateTime startdatetime = DateTime.Now;
var dirs = from dir in
Directory.EnumerateDirectories("W:\\", "*Final*", SearchOption.AllDirectories)
select dir;
foreach (var dir in dirs)
{
    Console.WriteLine(dir);
}
DateTime EndDate = DateTime.Now;
TimeSpan t = EndDate - startdatetime;
Console.WriteLine(t.Minutes);
Console.ReadLine();

This gave me only folders not file names in 5 minutes on first run and 6 minutes on second.
Old code which i used to get only folders was

DateTime startdatetime = DateTime.Now;
string[] dirs = 
    Directory.GetDirectories("W:\\", "*Final*", SearchOption.AllDirectories);
foreach (var dir in dirs)
{
    Console.WriteLine(dir);
}
DateTime EndDate = DateTime.Now;
TimeSpan t = EndDate - startdatetime;
Console.WriteLine(t.Minutes);
Console.ReadLine();

The above code gave me list of folders in 6-7 minutes.
Combined Files and Folders above code gave results in 12 minutes. That is huge performance penalty on web.

Any idea guys how to reduce this penalty cap? I am stuck here.

  • 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-05-31T12:33:40+00:00Added an answer on May 31, 2026 at 12:33 pm

    I feel iterating entire directory and files is very costly. Try to find out why you need that. Why not to get one directory and search files inside it. I mean try to do some analysis with your tech team and business owners so that every one is realistic.

    The only thing that I can think of is using Parallel for each loop rather than the normal one so that you can utilize your CPU’s. But it will reduce the cost but not drastically.

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

Sidebar

Related Questions

I have a file on a Windows 2003 server which is locked by a
I have a large server log file (~750 MB) which I can't open with
I have an Access file on a server which my colleagues will update regularly
We have a file share on a debian server which people will be putting
I have a web server which returns an XML file. Lets say http://www.foo.bar/foo.php?wantXML=1 How
I have a log file from a web server which looks like this; 1908
I have an HTTP server which host some large file and have python clients
I have to develop a file server service that transfer file form a specified
I have been working on designing a file server that could take the load
I'm using PuTTY to access my BSD file server and I have several terminal

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.