Search code examples
c#filesystemwatcher

How to Get the deleted File/Folders using FileSystemWatcher


How to get the complete list of deleted files if user delete the a root folder:

Ex: c:\A\B\C\D\F\read.txt

If user delete the root folder A, I need to get the files/folders realted to A, Is there any API in C# for this?

Can we get use the root folder path and retrieve the related files from teh RecycleBin? I dont't know if user clicks Shift + Delete, how we can get it from RecyleBIn


Solution

  • No there isn't an API that will tell you which files have been deleted. You could list the contents of the Recycle Bin but it is not guaranteed to be accurate (because of the reason you describe in your question: Shift+Delete).

    Short of maintaining a list of existing files at any point in time or monitoring disk changes with FileSystemWatcher (or possibly an OS filter driver), I think you're out of luck.

    I am curious though, why would you want to?