USB drive ejection blocked

Heiko 1,191 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?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,663 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,412 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,177 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,513 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,356 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