在.Net中如何監視文件是否被其他程序訪問(打開)?我無法在FileSystemWatcher中看到OnOpened事件,所以我認爲它不能這樣做。有沒有其他方法可以做到這一點?在Windows中顯然是可能的,是否有.Net提供的某種鉤子?FileSystemWatcher OnOpened事件
3
A
回答
4
查看NotifyFilters屬性。您可能想要查看訪問日期/時間的更改。
2
NotifyFilters枚舉有趣的你值:LastAccess指示最後一個文件或目錄訪問。這必須設置爲NotifyFilter屬性。
相關問題
- 1. FileSystemWatcher OnChanged事件
- 2. FileSystemWatcher複製事件
- 3. FileSystemWatcher不觸發事件
- 4. Filter FileSystemWatcher已更改事件
- 5. FileSystemWatcher不發射事件
- 6. FileSystemWatcher沒有觸發事件
- 7. FileSystemWatcher,取消訂閱事件
- 8. FileSystemWatcher停止捕獲事件
- 9. FileSystemWatcher提高多個事件
- 10. Filesystemwatcher不會觸發事件
- 11. FileSystemWatcher刪除事件處理程序
- 12. FileSystemWatcher得到太多的事件
- 13. FileSystemWatcher的事件不觸發C#
- 14. FileSystemWatcher事件觸發器問題
- 15. 一次引發FileSystemWatcher的多個事件
- 16. 測試引發的事件由FileSystemWatcher的
- 17. FileSystemWatcher - 更改只讀屬性的事件
- 18. 從FileSystemWatcher捕獲丟失事件C#
- 19. 哪個用戶導致FileSystemWatcher事件?
- 20. FilesystemWatcher只觸發一次事件
- 21. 從FileSystemWatcher事件更新列表框
- 22. FileSystemWatcher沒有調用更改事件
- 23. 在FileSystemWatcher事件上的ASP.net Response.Redirect
- 24. FileSystemWatcher的生成創建事件
- 25. FileSystemWatcher的更改不會觸發事件
- 26. FileSystemWatcher
- 27. FileSystemWatcher
- 28. FileSystemWatcher InternalBufferOverflow
- 29. FileSystemWatcher丟失文件
- 30. FileSystemWatcher ArgumentException
然後它會引發OnChanged事件嗎? – 2011-03-16 23:56:16
@HeavyWave是的,它會引發OnChange事件。查看FileSystemEventArgs的ChangeType屬性以確定發生了什麼變化 - 如果這對你很重要。 – SRM 2011-03-17 00:05:37