Unmount a USB Pen-Drive via Code

7

I would like to know how I can do to unmount a removable drive (Pen-Drive) via C # code.

    
asked by anonymous 21.02.2014 / 17:59

3 answers

3

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);
}
    
21.02.2014 / 19:39
2

So guys, I was able to find a program that does this.

link

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.

    
21.02.2014 / 18:33
2

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! :)

link

    
21.02.2014 / 18:19