I’m am writing a program to search files within a certain directory but seem to have some lag issues. The folder I’m searching has 500 files and around 1000 folders that hold these files.
There might be a folder within a folder(THE 2nd LEVEL).
I am using the lines below to grab all my files.
string location = "C:\\Documents and Settings\\All Users\\Documents\\PDFS";
string[] PDFS = Directory.GetFiles(@location, "*pdf", SearchOption.AllDirectories);
My current setup is MS Visual C# 2010 Express.
You can use
Directory.EnumerateFiles()instead which uses lazy evaluation, so files are only brought into memory as you iterate over the results.