Last post Jun 22, 2013 07:31 AM by SreeRama87
Jun 18, 2013 07:28 AM|SreeRama87|LINK
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.
Jun 18, 2013 05:55 PM|N_EvilScott|LINK
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
Jun 19, 2013 05:25 AM|SreeRama87|LINK
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.
Jun 19, 2013 05:43 PM|N_EvilScott|LINK
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.
Jun 22, 2013 07:31 AM|SreeRama87|LINK
Will check this one..... Scott.