Issue:
Using Windows Explorer to enumerate and display a large number of files (200,000 or more) in a single directory can be very slow (45 seconds or more). During this time Windows Explorer may appear to hang or become unresponsive.
Cause:
Windows Explorer first reads the contents of the folder via the QueryDirectory command. After the contents are read Windows Explorer must format the output based upon the current sort order (Name, Size, Type, or Date Modified). Windows Explorer must also populate the directory contents into the display columns for display to the user, which is also time consuming. It is this formatting and display process that is delaying the display of the folder contents.
Because the issue really resides with the formatting and presentation of the directory structure, other products designed to replace Windows Explorer may have this same issue.
Workaround:
To list the contents of a folder containing a large number of files faster use the Command Prompt and issue the “DIR” command while redirecting output to a text file.
Example: “DIR C:\LargeFolder > C:\Filename.txt”
By redirecting output to a text file you can use notepad to open the file and display the contents. You can then search the contents of the text file for any filename, date or time that may be of interest.
More Information:
You can verify that Windows Explorer quickly finishes reading the contents of the folder by using one of two SysInternals utilities: File Monitor or Process Monitor. By looking at the time stamp associated with the start and stop of the QueryDirectory command on the associated folder you can determine the amount of time taken to read the directory contents.
In a test using 275,000 files in a single folder Windows Explorer (monitored with File Monitor) successfully read the folder contents in less than 5 seconds, but would take a full 60 seconds or more to display the information to the screen.
To demonstratr the issue lies with sorting and formatting the output you can use the “DIR” command. Run the following commands to demonstrate the speed at which the directory filenames are retrieved (the first command) versus the time it would take to sort and display the results (the second command).
Sample Command Prompt Tests:
1) Type “DIR C:\LargeFolder”
a. The filenames will return instantly sorted by name first (NTFS automatically sorts files by name).
2) Type “DIR C:\LargeFolder /odsn”
a. The filenames will display after the following sort takes place: date/time, file size, and file name.
b. This sort can take 5-20 seconds (or more) to process prior to displaying the information to the screen.