Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The link you provided is the most efficient way in C# (with .Net 4.0): <a href="http://msdn.microsoft.com/en-us/library/dd383458" rel="nofollow noreferrer">Directory.EnumerateFiles Method</a></p> <p>Prior versions of .Net had to use a slower method that caused memory issues on large drives, @hatchet showed a great example: <a href="https://stackoverflow.com/questions/724148/is-there-a-faster-way-to-scan-through-a-directory-recursively-in-net">Is there a faster way to scan through a directory recursively in .NET?</a></p> <p>I wouldn't suggest using the TPL as Jon Skeet mentions here: <a href="https://stackoverflow.com/questions/4149873/task-parallel-library-for-directory-traversal#comment14095131_4149873">Task Parallel Library for directory traversal</a></p> <p>If you see the first comment in this <a href="http://msdn.microsoft.com/en-us/library/ff477033.aspx" rel="nofollow noreferrer">MSDN link: Iterate File Directories with the Parallel Class</a> I dont even think Microsoft had success with this TPL method either.</p> <p>The other suggestion I have is using LogParser and you can use it with C#! Its a free Microsoft product but I'm not sure about re-dist permissions, I had to include it in my package separately last time I used it. It full on flys, faster than a speeding train!</p> <p>As per @spender comment I found a <a href="http://forums.iis.net/t/1183252.aspx" rel="nofollow noreferrer">Log Parser example</a> that finds files dated 180 days and older, you could try it out and adapt it if its useful:</p> <pre><code>SELECT ContentPath, [Days (Old)], FileName, [Creation Date Time] USING creationtime AS [Creation Date Time], TO_DATE([Creation Date Time]) AS Cdate, SUB(TO_LOCALTIME(SYSTEM_TIMESTAMP()), Cdate) AS Days, DIV(TO_INT(Days),86400) As [Days (Old)], EXTRACT_PATH(TO_LOWERCASE(path)) AS ContentPath, TO_LOWERCASE(name) AS FileName FROM %source% WHERE (attributes NOT LIKE 'D%') AND ([Days (Old)] &gt;= TO_INT('%day%')) ORDER BY [Creation Date Time] DESC </code></pre> <p>%source% could be something like c:\*.exe as shown in the argument c:\temp\*.*. Save the above as cc.sql, run it with the following syntax:</p> <pre><code> C:\Temp\Tools\Logparser&gt;LogParser.exe file:cc.sql?source="c:\temp\*.*"+day="180" -i:FS -preserveLastAccTime -rtp:-1 </code></pre> <p><strong>EDIT</strong></p> <p>Thanks for the upvotes guys! I made this <a href="http://EventAnalyser.AppointmentsBook.com" rel="nofollow noreferrer">Event Analyser</a> app in 2005 (before .net 2.0 was released) and since the Log Parser suggestion was so popular I thought I'd share the way you can use LogParser in .Net</p> <blockquote> <p>The good folks over at <a href="http://visuallogparser.codeplex.com/" rel="nofollow noreferrer">http://visuallogparser.codeplex.com/</a> have provided us with the source code.</p> </blockquote> <p>Open the <a href="http://visuallogparser.codeplex.com/" rel="nofollow noreferrer">VisualLogParser</a> solution in VS2010, ignore the prompt about debugging, after the solution loads, F5, set the combo-box to FS (FileSystem), paste in this query and press go. </p> <pre><code>SELECT     ContentPath, [Days (Old)], FileName, [Creation Date Time]     USING creationtime AS [Creation Date Time],     TO_DATE([Creation Date Time]) AS Cdate,     SUB(TO_LOCALTIME(SYSTEM_TIMESTAMP()), Cdate) AS Days,     DIV(TO_INT(Days),86400) As [Days (Old)],     EXTRACT_PATH(TO_LOWERCASE(path)) AS ContentPath,     TO_LOWERCASE(name) AS FileName FROM 'c:\*.exe'  WHERE   (attributes NOT LIKE 'D%') AND   ([Days (Old)] &gt;= TO_INT('180')) ORDER BY [Creation Date Time] DESC </code></pre> <p><em>At the same time you may wish run any other .Net application that searches directories and compare the results!!!</em></p>
 

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