Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What about creating your own directory traversal function and using the <a href="http://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx" rel="nofollow noreferrer">C# <code>yield</code> operator</a>?</p> <p>EDIT: I've made a simple test, I don't know if it's exactly what you need.</p> <pre><code>class Program { static string PATH = "F:\\users\\llopez\\media\\photos"; static Func&lt;string, bool&gt; WHERE = s =&gt; s.EndsWith(".CR2") || s.EndsWith(".html"); static void Main(string[] args) { using (new Profiler()) { var accepted = Directory.GetFiles(PATH, "*.*", SearchOption.AllDirectories) .Where(WHERE); foreach (string f in accepted) { } } using (new Profiler()) { var files = traverse(PATH, WHERE); foreach (string f in files) { } } Console.ReadLine(); } static IEnumerable&lt;string&gt; traverse(string path, Func&lt;string, bool&gt; filter) { foreach (string f in Directory.GetFiles(path).Where(filter)) { yield return f; } foreach (string d in Directory.GetDirectories(path)) { foreach (string f in traverse(d, filter)) { yield return f; } } } } class Profiler : IDisposable { private Stopwatch stopwatch; public Profiler() { this.stopwatch = new Stopwatch(); this.stopwatch.Start(); } public void Dispose() { stopwatch.Stop(); Console.WriteLine("Runing time: {0}ms", this.stopwatch.ElapsedMilliseconds); Console.WriteLine("GC.GetTotalMemory(false): {0}", GC.GetTotalMemory(false)); } } </code></pre> <p>I know that you cannot rely to much on <a href="http://msdn.microsoft.com/en-us/library/system.gc.gettotalmemory(VS.71).aspx" rel="nofollow noreferrer"><code>GC.GetTotalMemory</code></a> for memory profiling, but in all my test runs display a little less memory consumption around(100K).</p> <pre>Runing time: 605ms GC.GetTotalMemory(false): 3444684 Runing time: 577ms GC.GetTotalMemory(false): 3293368</pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload