I'm using the FileSystemWatcher to monitor a certain directory, and I need to raise one event when someone saves edits to a file, and another when they create or move a file.
Monitoring moved files works fine using a combination of the Deleted and Created events. And when someone saves edits to a file the Changed event does indeed get raised. However, when they move a file the Changed event gets raised too, and that interferes with the handling I've got for the Created and Deleted events.
So basically, I want to raise the Changed event only when the user saves edits to a file, while not when the user moves or creates a file. I tried using the ChangeType property to check if it was in fact a Changed event or a Created event, but to my surprise, the ChangeType Changed was raised for the Change event even when moving or creating a file, not the ChangeType Created (which supposedly should be one of the types).
So I don't know how to check that the Change event is actually triggered by a file edit, rather than file creation or move...
Any ideas?
This is normal behavior when you apply some of NotificationFilter such as NotifyFilter. Attributes and NotifyFilter.LastAccess, it will even notify Changed twice if both filters was applied when file move "Deleted - Created - Changed - Changed", So:
Simply don't add not relevant notify filters; If you just remove
NotifyFilter. Attributes and NotifyFilter.LastAccess
you will not receive Changed event when move file, only Deleted then Created.
If you are wishes to stick with the notify filters that you are already using, there is other hint here to allow you to generate a dirty solution, it is the fact that when the file moved, the sequence of notification will be Deleted, Created then Changed, they will be always in this order..
Related
I've been struggling with this for quite a while
My wpf application contains a list view, populated with file-names, which are located on a server.
I'm trying to implement drag and drop functionality, so the user can drag files from my application into his/her's local computer.
In order to do this, first i'm downloading the files into a temporary location, and then calling my application's DoDragDrop() method.
The problem is that I want to perform the download process only after the DoDragDrop method is called.
I've tried every event related to drag drop methods (GiveFeedback, ItemDrag, etc...) but nothing works
so basically what I need is an event, raised after the DoDragDrop is done
any ideas?
The current scheme is to drag a file with a special suffix, and then turn on global file monitoring to obtain the drag location of the file through monitoring.
I need to change the category of a email when the inspector-window is closing - what I am doing with the Close event.
My problem is, if the user clicks "move to folder" in the inspector, the mail is moved, after this the close event is fired, but at this point I coannot change the mail any more, because it was changed trough the mail-move (eg: EntryID gets changed).
Any ideas?
An "before-Item-moved" event on the mail would be great - or a way to reload the changed mail.
Unfortunately there's no easy way to get folder that the email was moved to. Which means you'll have to use Redemption which has events for the RDOStore object that can detect changes to any folder. But you'd also have to monitor EVERY store, because the user can obviously move it anywhere. And because the EntryID has changed, you'd need to use PR_SEARCH_KEY as the unique identifier in order to even find the email and then apply the category to it. Not fun!
Another option may be to repurpose the Move To Ribbon button to intercept the move operation, but then you'd have to provide your own folder picker! Ugly!
There is a BeforeMove event available:
https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.inspectorevents_10_event.beforemove%28v=office.14%29.aspx
I have two applications having reference to same xml file. One writes to the file, other monitors changes to the file.
In Application 1, I have used FileSystemWatcher to monitor changes, applied filter as LastWrite and watching for change event only. It runs continously in background
Application 2 reads a specific node in the file at startup and updates the node on users direction. Its a simple windows form, that reads a value from file when executed, and has the facility to change that value
Strange thing I came across when running both the applications, is that when application 2 starts up, file change event is raised in application 1 (Note: Application 1 continously watches the file)
I want to get rid of the change event raising in application 1 when application 2 starts up.
Is the filter incorrect or the Change event behaving nasty?
This behavior is documented:
The Changed event is raised when changes are made to the size, system
attributes, last write time, last access time, or security permissions
of a file or directory in the directory being monitored.
If Application 2 opens the file and the OS keeps track of last access times, a Changed event will be raised. Since there's no facility to filter only those events that actually write data to the file, you will have to determine what happened by keeping state on Application 1.
For example, now that you know what's going on you can keep a cache of the last write time and decide to ignore the event if that hasn't changed.
I am using a Input system which manages input from all controllers, keyboard, etc. If you would like to check it out visit: http://mquandt.com/blog/2010/01/xna-input-manager-sample/
I have modified that input manager to have a queue system so that (in theory) would stop the event triggering to boil over when in the middle of a update.
Here is a bare bones example of my issue (This uses the XNA 4.0 framework):
http://www.mediafire.com/?9ynabpvls19u0sq
To explain my problem better if you don't want to download:
An input bind is created. After trigger the bind is deleted and a new one is added. But the same button press to delete and add the new one triggers the one that was added. This cycle continues with any number of binds. One->Three
What should happen is that on button press, old one is deleted and new one is added. Then after another button press add, delete, etc. One->Two->Three
I have figured out that if I add a breakpoint or a thread sleep of 100ms on the ActionDown of InputAction then it works correctly. I guess something is going wrong because it is going too fast but a thread sleep is not a solution.
Make DeActivate method where you can UnBind or destroy or disable your action.
I have a handle that fires when the ItemAdd event is triggered on the Sent Items folder in outlook. This handle prompts the user and depending on their selection then opens a custom windows form to save the sent email.
Now ... heres what happens ...
The prompt shows fine when an item is placed into the Sent Items folder, if you dismiss it it will show again fine the next time the event is triggered, and so on.
If you accept the prompt, the windows form shows and are able to save the email. But the next time an email is placed into the sent items folder the event doesnt fire, and hence the prompt doesnt even show!
if i put the same handle on Outlooks OnSend event instead of on the ItemAdd for the sent items folder all works just the same, except after the windows form is loaded the first time it will continue to be loaded (ie the event fires and is handled) perfectly the next time you want it to.
It appears showing the windows form for some reason causes either the event to stop firing or the handle to drop off the sent items folder (but only the sent items folder). The latter being more likely i think. I have an idea for a work around but im not really a fan of work arounds if i can get away with it.
Would anybody know what might be going on here?
Many thanks in advance to any thoughts people may have.
Cheers,
Stuv
I had a similar problem. It sounds like one of your variables is getting garbage collected. If you can post some code I might be able to help you.