Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How reliable is the FileSystemWatcher in .netFramwork 4?

Tags:

Has anyone used the FileSystemWatcher in framework 4 and have you encountered any problems?

i am using it in a windows service and i cant afford for it to fail.

I have heard from a friend that it is not very reliable but I have been testing for a few hours now and i havent had any problems but i am still doubting using it.....

i would appreciate any advice on this matter, i dont want to deliver the app to the the client and then realise that this thing is going to crash....

Thanks


Thanks for the advice guys

i think for my purposes it should be ok. it will be checking a folder on the local drive of the server and all its checking for is if a file have been modified so i think it should be fine

like image 497
Yugz Avatar asked Aug 25 '11 13:08

Yugz


People also ask

Is FileSystemWatcher reliable?

FileSystemWatcher is "known to be unreliable". In simple words, it doesn't work well. If the data size of the collected watcher events exceeds the size of the buffer created by FileSystemWatcher, the events that overflow are lost, and reliable exceptions are not raised.

Is FileSystemWatcher multithreaded?

Nope, filesystemwatchers run on their own thread.

What is the use of FileSystemWatcher class in .NET framework?

Use FileSystemWatcher to watch for changes in a specified directory. You can watch for changes in files and subdirectories of the specified directory. You can create a component to watch files on a local computer, a network drive, or a remote computer.

Which of the following are types of changes that can be detected by the FileSystemWatcher?

The FileSystemWatcher lets you detect several types of changes in a directory or file, like the 'LastWrite' date and time, changes in the size of files or directories etc. It also helps you detect if a file or directory is deleted, renamed or created.


1 Answers

FileSystemWatcher relies on underlying file system support, so any reliability issues with the file system will be visible as reliability issues with FileSystemWatcher. For example, if you are watching a network directory, then the network server's reliability will affect FileSystemWatcher's reliability. For example, the server may crash and be restarted. You will not be notified of changes that take place while network connectivity is lost. Or the server may simply have a bug that prevents FileSystemWatcher from working reliably.

Another point is that FileSystemWatcher only watches for changes to metadata. Not all file changes result in changes to metadata.

like image 102
Raymond Chen Avatar answered Oct 18 '22 09:10

Raymond Chen