I'm trying to get a list of files in a specific directory that contains over 20 million files ranging from 2 to 20 KB each.
The problem is that my program throws the Out Of Memory Exception everytime, while tools like robocopy are doing a good job copying the folder to another directory with no problem at all. Here's the code I'm using to enumerate files:
List<string> files = new List<string>(Directory.EnumerateFiles(searchDir));
What should I do to solve this problem? Any help would be appreciated.