Remove Ads

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C# File Watcher not raising events accurately on DSM 6.2 in subfolders
#1
Hello,

I am unsure whether this is the correct thread, but feels like my request fits here the most.

I am writing a C# service to monitor a Synology DSM 6.2 NAS and I am using c# file system watcher to monitor for file changes.
The disk is quite large so I scan it whole on startup (takes about 12-14 minutes), keep track of certain files and watch for changes on all files and check on changes whether the change interests us, notify worker thread to process this file.

Despite FileWatcher (let's call it FW) raising accurately events on change in the files content in the whole file tree (gets raised 3 times but doesn't matter) and OnCreated (only if created in file explorer), but some other events (for files not located in the FW root folder) do not get registered, mainly copying and renaming files.

Lets say the root folder of FW is in the folder foo/, then copying files into foo/ gets registered and event is raised as expected, renaming the same.
But if we have a folder bar/ inside foo/, then copying files into foo/bar/, and any other subfolder of foo, doesn't get noticed. So if I copy file a.txt to foo/bar/a.txt, the FW doesn't register and my application doesn't know. However, changing the file foo/bar/a.txt and saving it raises the OnChanged event and I can process the file.
If I open foo/bar/ in file explorer, I create new file, the events gets raised for oncreate with the default name, when setting the name, the event for rename doesn't get raised. Editing the file content raises OnChanged.

Right now the workaround is rescan the whole disk in intervals, but I'd like to avoid that. Has someone encountered similiar problem or has any advice that could help?

Here is a code snippet https://gitlab.com/klicka-jan/file-watch...Watcher.cs (I created the class by hand in gitlab, it's essentialy copy paste of my code with everything that doesn't involve file watcher removed)
Reply
#2
Sorry - beyond my expertise. I can see what you want to do, but I have no idea what changes will be needed in the O/S to enable it.
Alan
Forum administrator
Reply


Forum Jump:


Users browsing this thread:

Remove Ads