FileSystemWatcher provide us different kind of events from changed to deleted. I was wondering why I'm getting deleted event whenever I used v开发者_开发技巧isual studio 2005 to edit a file and changed event if I'm using notepad or notepad++ and other editor?
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.
精彩评论