locked
Issue with File watcher component RRS feed

  • Question

  • User306497674 posted

    Dear Team,

    I'm trying to work with Filewatcher service, some times it is picking the changes in the folder and most of the times it is not picking any, 

    currently i'm using changed and created events.

    Please help me in solving these issue and let me know incase of any further info.

    Thanks

    Ravi

    Tuesday, June 18, 2013 7:28 AM

Answers

  • User-1528094326 posted

    First note that this is an ASP.NET forum so Windows Services are not supported, but since I know a little bit about the FileSystemWatcher I can say this much....

    The FileSystemWatcher can be sporatic and tempermental given the appropriate conditions. It could be a number of things, but my first suggestion would be to subscribe to the OnError event, and see if you get a InternalBufferOverflowException at any point. If that's the case you can try doubling the size of the buffer and see if it fixes any ills.

    Besides that make sure you are subscribing to the appropriate events. As an example as funny as it sounds, when you cut and paste a file into the specified directory its actually under the covers doing a "Renaming" operation so you would need to ideally subscribe to the Renamed event. Created will fire when the file is freshly just created period, and Changed will fire if the file has been modified or copied etc.

    Start with the OnError and record anything that happens.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 19, 2013 5:43 PM

All replies

  • User-1528094326 posted

    Sometimes rapid notifications in succession can cause buffer overflows. Microsoft describes it like this:

    The Windows operating system notifies your component of file changes in a buffer created by the FileSystemWatcher. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification. Increasing the size of the buffer with the InternalBufferSize property is expensive, as it comes from non-paged memory that cannot be swapped out to disk, so keep the buffer as small yet large enough to not miss any file change events. To avoid a buffer overflow, use the NotifyFilter and IncludeSubdirectoriesproperties so you can filter out unwanted change notifications.

    You can find more info on the FileSystemWatcher here

    http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx

    Tuesday, June 18, 2013 5:55 PM
  • User306497674 posted

    Thanks scott for the reply,

    I have been using NotifyFiter :FileName, DirectoryName, LastWrite , IncludeSubDirectories: False  as I dont want filwatcher to act if any changes in the sub directory,  some times it is picking the files and sometimes not.

    I have been using the filter : *.bin , but it is not picking up the files  and next I have tried with *.* then also it not picking up any files for processing.

    I'll explain what I have done.First I have implemented Filwatcher in a windows service and then it worked fine for that day, from the next day onwards it stopped working.So I took new windows service and implemented the FileWatcher again it worked for 2 days and it stopped working again

    I'm not able to understand the issue over here.Pl. help me in solving this issue.

    Please let me know if you want more information.

    Thanks

    Ravi.

    Wednesday, June 19, 2013 5:25 AM
  • User-1528094326 posted

    First note that this is an ASP.NET forum so Windows Services are not supported, but since I know a little bit about the FileSystemWatcher I can say this much....

    The FileSystemWatcher can be sporatic and tempermental given the appropriate conditions. It could be a number of things, but my first suggestion would be to subscribe to the OnError event, and see if you get a InternalBufferOverflowException at any point. If that's the case you can try doubling the size of the buffer and see if it fixes any ills.

    Besides that make sure you are subscribing to the appropriate events. As an example as funny as it sounds, when you cut and paste a file into the specified directory its actually under the covers doing a "Renaming" operation so you would need to ideally subscribe to the Renamed event. Created will fire when the file is freshly just created period, and Changed will fire if the file has been modified or copied etc.

    Start with the OnError and record anything that happens.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 19, 2013 5:43 PM
  • User306497674 posted

    Will check this one..... Scott.

    Saturday, June 22, 2013 7:31 AM