I would like to know how I can do to unmount a removable drive (Pen-Drive) via C # code.
I would like to know how I can do to unmount a removable drive (Pen-Drive) via C # code.
From Windows XP you can use the native command MOUNTVOL
. According to its documentation:
Creates, deletes, or lists at volume mount point.
Mountvol
is a way to link volumes without requiring a drive letter.
Translating:
Creates, deletes, or lists a mount point volume.
Mountvol
is a way to bind volumes without the need for a drive letter.
Using your code as a base, this would be the call without the need for any external components:
private static void EjectDrive(char driveLetter)
{
ProcessStartInfo ps = new ProcessStartInfo("mountvol.exe", driveLetter + ": /d");
Process.Start(ps);
}
So guys, I was able to find a program that does this.
And I did it that way.
private static void EjectDrive(char driveLetter)
{
ProcessStartInfo ps = new ProcessStartInfo("RemoveDrive.exe", driveLetter + ":");
Process.Start(ps);
}
Along with this RemoveDrive at the root of the program. Obg Galera.
At this link, I was trying to make the same solution and I had found this template, but it was not accurate, I used file transfer via Dropbox, so I abandoned the project.
Who knows, it gives you a light! :)