USB drive ejection blocked

Heiko 1,291 Reputation points
2023-03-05T17:30:00.0333333+00:00

The user can plug in any folder from any drive into my app, so also from USB drives. The app is then watching the folders changes by using FileSystemWatcher. But if the user wants to eject the drive by clicking the icon in the task notification area, it cannot be removed because obviously the FileSystemWatcher keeps this drive in usage. If I use Spy++, I connot see that my app gets any windows message which could inform my MainWindow that a ejection is requested. How can I get an information about the ejection request, so that my app can remove the FileSystemWatcher for that drive and doesn't block this operation?

Developer technologies | Windows Presentation Foundation
Windows development | Windows API - Win32
Developer technologies | C++
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,686 Reputation points
    2023-03-05T17:57:57.6066667+00:00

    How can I get an information about the ejection request, so that my app can remove the FileSystemWatcher for that drive and doesn't block this operation?

    Detecting Media Insertion or Removal

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.