FileSystemWatcher provide us different kind of events from changed to deleted. I was wondering why I'm getting deleted event whenever I used visual studio 2005 to edit a file and changed event if I'm using notepad or notepad++ and other editor?
+2
A:
Standard operation for programs that want to avoid losing everything:
- Rename original file
- Create new file with original name
- Write and close file
- No problems: delete file from step 1
If something goes wrong, the renamed file is restored. Your other editor would corrupt the original if something goes wrong while writing.
Hans Passant
2010-07-06 03:09:10
Sorry Hans but your comments does not answer my question. I asked why FileSystemWatcher instance is firing deleted event if I "edited" a specific file using VS2005. I was expecting that it would fire Changed event. Anyways thanks your comments.
powerbox
2010-07-06 03:13:44
Pay attention to step #4.
Hans Passant
2010-07-06 03:21:37
hmm thanks I got your point. I'm getting a temporary file on deleted event but I never get the changed event.
powerbox
2010-07-06 03:26:43
Review steps 1 through 3, nothing is getting changed. The temporary file got created at step 1.
Hans Passant
2010-07-06 03:28:54