protected override void OnDoWork(DoWorkEventArgs e)
        {
            bool res = true;

            char letter = driveInfo.RootDirectory.Name[0];

            try
            {
                for (int tries = 0; tries < 5; tries++)
                {
                    res = DriveManager.EjectDrive(letter);
                    //TODO: Try this - https://stackoverflow.com/questions/58735900/how-to-eject-usb-drive-on-windows-10-ioctl-storage-eject-media-no-longer-enough

                    Thread.Sleep(5000);

                    if (res)
                    {
                        break;
                    }
                }
            }
            catch
            {
                res = false;
            }


            e.Result = res;
        }
Beispiel #2
0
        protected override void OnDoWork(DoWorkEventArgs e)
        {
            bool res = true;

            char letter = driveInfo.RootDirectory.Name[0];

            try
            {
                // Check supported file system
                if (!supportedFilesystems.Contains(filesystem))
                {
                    res = false;
                }
                else
                {
                    res = DriveManager.FormatDrive(letter, driveInfo.VolumeLabel, filesystem);

                    Thread.Sleep(2000);
                }
            }
            catch
            {
                res = false;
            }


            e.Result = res;
        }