Ryan Foster
Ryan Foster

Reputation: 51

C# Fastest way to grab all of the subdirectories from a given path

I'm using Directory.GetDirectories(path, "*", SearchOption.AllDirectories) to get all of the paths, but for directories containing larger amounts of subfolders it can take quite a while for it to complete (upwards of 5 minutes or so with 50k folders).

I'm using Unity and am stuck with .NET 2.0, so I can't use Directory.EnumerateDirectories() which I've heard is faster. The only way I can think of to make it faster is to run similar code on a separate thread and just iterate through the available paths, but I'm wondering if there's either a better way or one that's just plain faster.

Upvotes: 0

Views: 169

Answers (0)

Related Questions