<p>I'm using MSVE, and I have my own tiles I'm displaying in layers on top. Problem is, there's a ton of them, and they're on a network server. In certain directories, there are something on the order of 30,000+ files. Initially I called Directory.GetFiles, but once I started testing in a pseudo-real environment, it timed out.</p>

<p>What's the best way to programatically list, and iterate through, this many files?</p>

<p>Edit: My coworker suggested using the MS indexing service. Has anyone tried this approach, and (how) has it worked?</p>

[{'answer_id': 3552, 'author': 'Ronnie', 'author_id': 193, 'author_profile': 'https://Stackoverflow.com/users/193', 'pm_score': 4, 'selected': True, 'text': "<p>I've worked on a SAN system in the past with telephony audio recordings which had issues with numbers of files in a single folder - that system became unusable somewhere near 5,000 (on Windows 2000 Advanced Server with an application in C#.Net 1.1)- the only sensible solution that we came up with was to change the folder structure so that there were a more reasonable number of files. Interestingly Explorer would also time out!</p>\n\n<p>The convention we came up with was a structure that broke the structure up in years, months and days - but that will depend upon your system and whether you can control the directory structure...</p>\n"}, {'answer_id': 3570, 'author': 'Stu', 'author_id': 414, 'author_profile': 'https://Stackoverflow.com/users/414', 'pm_score': 1, 'selected': False, 'text': '<p>None. .NET relies on underlying Windows API calls that really, really hate that amount of files themselves.</p>\n\n<p>As Ronnie says: split them up.</p>\n'}, {'answer_id': 3583, 'author': 'GateKiller', 'author_id': 383, 'author_profile': 'https://Stackoverflow.com/users/383', 'pm_score': 1, 'selected': False, 'text': '<p>You could use DOS?</p>\n\n<pre><code>DIR /s/b &gt; Files.txt\n</code></pre>\n'}, {'answer_id': 3600, 'author': 'Greg Hurlman', 'author_id': 35, 'author_profile': 'https://Stackoverflow.com/users/35', 'pm_score': 2, 'selected': False, 'text': '<p>Definitely split them up.  That said, stay as far away from the Indexing Service as you can.</p>\n'}, {'answer_id': 4147, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 1, 'selected': False, 'text': '<p>You could also look at either indexing the files yourself, or getting a third part app like google desktop or <a href="http://www.copernic.com/en/products/desktop-search/whats-new-15.html" rel="nofollow noreferrer">copernic</a> to do it and then interface with their index. I know copernic has an API that you can use to search for any file in their index and it also supports mapping network drives.</p>\n'}]
['https://Stackoverflow.com/questions/3512', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/517/']