Answered by:
FileSyncProvider keeps detecting changes

Question
-
static void Main(string[] args) { FileSyncOptions option = FileSyncOptions.ExplicitDetectChanges | FileSyncOptions.CompareFileStreams; FileSyncScopeFilter filter = new FileSyncScopeFilter(); FileSyncProvider provider = new FileSyncProvider(new Guid("{6413337A-2F05-4c5e-A7CF-2337CE4F4B0C}"), @"c:\SomeFolder", filter, option); provider.DetectedChanges += new EventHandler<DetectedChangesEventArgs>(provider_DetectedChanges); provider.DetectChanges(); provider.DetectChanges(); } static void provider_DetectedChanges(object sender, DetectedChangesEventArgs e) { Console.WriteLine("Total files found:" + e.TotalFilesFound.ToString()); }
The code stopped reporting false positives till I added:
filter.AttributeExcludeMask =
FileAttributes.Archive;
Anyone know what's the reason of this behavior?Thursday, March 18, 2010 1:23 AM
Answers
-
you could turn on auditing on a file to see who is touching it.
- Marked as answer by Friendly Dog IIMicrosoft employee Thursday, March 18, 2010 10:35 PM
Thursday, March 18, 2010 8:26 PM -
OK. I traced the sync framework and found that GetIsLocalFileChanged returned 0 for all the files. So there WERE no changes detected. Then I looked at documentation of DetectedChangesEventArgs.TotalFilesFound property. It says: "Gets the total number of files that are found during change detection." Ha! It doesn't say number of *changed* files, but *total number of files*.
The reason I "Stopped false positive" was because I excluded all files (because of the archive attribute).
So the whole thing is a stupid misunderstanding after all!!!!!!!
Thanks Sid for help!- Marked as answer by Friendly Dog IIMicrosoft employee Thursday, March 18, 2010 10:35 PM
Thursday, March 18, 2010 10:35 PM
All replies
-
It is possible there is another program or utility that is touching that file and setting the bit. It could be anti-virus program or xcopy or something else?
- Marked as answer by Friendly Dog IIMicrosoft employee Thursday, March 18, 2010 10:35 PM
- Unmarked as answer by Friendly Dog IIMicrosoft employee Thursday, March 18, 2010 10:35 PM
Thursday, March 18, 2010 5:22 PM -
There's no anti-virus or xcopy. The only thing I can think of is that the folder is indexed.
Thursday, March 18, 2010 6:35 PM -
you could turn on auditing on a file to see who is touching it.
- Marked as answer by Friendly Dog IIMicrosoft employee Thursday, March 18, 2010 10:35 PM
Thursday, March 18, 2010 8:26 PM -
I used FileMon to monitor my local folder. Sure enough, SearchProtocolHost.exe (Windows Search service) accesses the folder once a while. I stopped the service and observed no other process operates on the folder. Then I tried a common folder: C:\Users\Public\Pictures\Sample Pictures - go the same behavior: FileSyncProvider constantly detects changes unless Archive attribute is filtered out.
Note in the above code I'm calling DetectChanges() multiple times and I get consistant results (all files are changed). I tried to call the method in a loop for 20 times, same result.Thursday, March 18, 2010 9:45 PM -
OK. I traced the sync framework and found that GetIsLocalFileChanged returned 0 for all the files. So there WERE no changes detected. Then I looked at documentation of DetectedChangesEventArgs.TotalFilesFound property. It says: "Gets the total number of files that are found during change detection." Ha! It doesn't say number of *changed* files, but *total number of files*.
The reason I "Stopped false positive" was because I excluded all files (because of the archive attribute).
So the whole thing is a stupid misunderstanding after all!!!!!!!
Thanks Sid for help!- Marked as answer by Friendly Dog IIMicrosoft employee Thursday, March 18, 2010 10:35 PM
Thursday, March 18, 2010 10:35 PM -
ah - glad to know you got to the bottom of thisFriday, March 19, 2010 12:09 AM