Is it possible to access a file before it's deleted when using FileSystemWatcher.OnDeleted
event?
I'm storing some data about the document itself in its metadata and i need that info before it's deleted.
Any Ideas how to accomplish this with or without FileSystemWatcher
if it's even possible ?
Update ://
I realized that storing the data in the file is bad as i cannot access it when file is deleted.
Solution : rewrite my app to store the data in a local database(sqlite/xml or something like that) as i get the full path and name when the file is being created/renamed/updated/deleted it would be easier to update the database record for the file.
Thanks to all for the ideas and suggestions!
Is it possible to access a file before it's deleted when using FileSystemWatcher.OnDeleted event?
The event is triggered after the file deletion not before, so you won't be able to access the file when this event is raised.
Any Ideas how to accomplish this if it's even possible ?
I would use the OnChanged
event instead, which is fired every time the file changes. Basically, you read the file metadata every time the file changes. This can be a bit cumbersome if the file gets updated very often but should allow you to have the latest metadata before the file is removed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With