In order to play a sound my c# program has to trigger every time the user deletes a file via the explorer in windows.
How can I do this? Is this even possible?
Edits:
To clarify: I want this to be some kind of a system hook. So it should not matter where the file is deleted.
I tried this:
m_watcher = new FileSystemWatcher();
m_watcher.Path = @"C:\";
m_watcher.Filter = "*.*";
m_watcher.IncludeSubdirectories = true;
m_watcher.EnableRaisingEvents = true;
m_watcher.Deleted += M_watcher_Deleted;
private void M_watcher_Deleted(object sender, FileSystemEventArgs e)
{
Debug.WriteLine("deleted");
}
but the problem is that I cant find out if M_watcher_Deleted is called as a result of a direct user action like pressing delete in the explorer. This is important because I want to play a sound. And if I am not able to differentiate between user actions and background actions with temporary files the sound will play all the time.