C# FileSystemWatcher Serious Problem?

前端 未结 4 1211
清歌不尽
清歌不尽 2021-01-21 03:42

I have implemented a FileSystemWatcher for a folder which resides on a NetworkStorage Device (having no O.S.).

The scenario is, we have two machine say

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-21 04:21

    FileSystemWatcher relies on the Operating System to Raise the Event. If there is no OS on the Storage Device there is no OS available to Raise the Event.

    Note that several factors can affect which file system change events are raised, as described by the following:

    Common file system operations might raise more than one event. For example, when a file is moved from one directory to another, several OnChanged and some OnCreated and OnDeleted events might be raised. Moving a file is a complex operation that consists of multiple simple operations, therefore raising multiple events. Likewise, some applications (for example, antivirus software) might cause additional file system events that are detected by FileSystemWatcher.

    The FileSystemWatcher can watch disks as long as they are not switched or removed. The FileSystemWatcher does not raise events for CDs and DVDs, because time stamps and properties cannot change. Remote computers must have one of the required platforms installed for the component to function properly.

    If multiple FileSystemWatcher objects are watching the same UNC path in Windows XP prior to Service Pack 1, or Windows 2000 SP2 or earlier, then only one of the objects will raise an event. On machines running Windows XP SP1 and newer, Windows 2000 SP3 or newer or Windows Server 2003, all FileSystemWatcher objects will raise the appropriate events.

    Setting the Filter property does not decrease what goes into the buffer.

    Note that a FileSystemWatcher does not raise an Error event when an event is missed or when the buffer size is exceeded, due to dependencies with the Windows operating system. To keep from missing events, follow these guidelines:

    Increasing the buffer size with the InternalBufferSize property can prevent missing file system change events.

    Avoid watching files with long file names. Consider renaming using shorter names.

    Keep your event handling code as short as possible.

    Source: MSDN Library Reference: FileSystemWatcher Class

提交回复
热议问题