Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am querying SystemIndex catlog to show recently added files in my application. But sometimes, SystemIndex is not bring up the very recently added files for my search. Do we have any fix for this issue?

My Query is like below

SELECT "System.ItemName", "System.ItemFolderPathDisplay" FROM "SystemIndex" WHERE CONTAINS(*,'"searchterm"',1033) AND (System.FileName LIKE '%.doc' OR System.FileName LIKE '%.txt') AND Contains(System.Kind, 'document') ORDER BY System.FileName ASC
Posted

1 solution

Unfortunately, WMI is neither efficient nor reliable when it comes to handling its events. As I figured out a while ago, such handling is based simply on regular polling, which is always bad. Please see:
http://en.wikipedia.org/wiki/Pull_technology[^],
http://en.wikipedia.org/wiki/Push_technology[^],
http://en.wikipedia.org/wiki/Polling_%28computer_science%29[^].

I mean, pull technology is always bad (when it comes to regular polling), push is good. In your case, at the moment when you query for files, they might not be currently polled, you have to wait for some indefinite time, when all files are finalized, closed, and then polled.

Alternatives? You could use System.IO.FileSystemWatcher:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110%29.aspx[^].

There is something you should be aware of though: the CodeProject member John Simmons / outlaw programmer reported these problems:
FileSystemWatcher - Pure Chaos (Part 1 of 2)[^],
FileSystemWatcher - Pure Chaos (Part 2 of 2)[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900