Created
February 18, 2018 03:47
-
-
Save arman-hpp/ac13912ea81962dfc5ea3049806eb2f7 to your computer and use it in GitHub Desktop.
Detect Volume
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ManagementEventWatcher watcher = new ManagementEventWatcher(); | |
WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent"); | |
watcher.EventArrived += Watcher_EventArrived; | |
watcher.Query = query; | |
watcher.Start(); | |
watcher.WaitForNextEvent(); | |
private static void Watcher_EventArrived(object sender, EventArrivedEventArgs e) | |
{ | |
var driveName = e.NewEvent.Properties["DriveName"].Value.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment