/// <summary> /// Is a FATX drive /// </summary> /// <param name="xDrive"></param> /// <param name="xType"></param> /// <returns></returns> public static bool IsFATX(ref Drive xDrive, out DriveTypes xType) { xType = DriveTypes.Unknown; if (xDrive == null) { return(false); } xDrive.MakeHandle(); DJsIO xIO = new DriveIO(xDrive, true); return(IsFATX(ref xIO, out xType)); }
private void FormatDrive() { // format if ( MessageBox.Show(Strings.FormatWillErase.Replace(@"\n", "\n"), "SharpBoot", MessageBoxButtons.YesNo) != DialogResult.Yes) { CancelWork(); return; } var tries = 1; while (true) { if (tries == 5) { MessageBox.Show(Strings.FormatError, "SharpBoot", MessageBoxButtons.OK, MessageBoxIcon.Error); CancelWork(); return; } ChangeProgress(0, 100, Strings.Formatting); var askform = new AskPath(); askform.SetTextMode(Text, Strings.VolumeLabel, string.Concat(Title.Where(char.IsLetter))); var volumeLabel = ""; if (askform.ShowDialog() == DialogResult.OK) { volumeLabel = askform.FileName; } else { CancelWork(); return; } var res = DriveIO.FormatDrive(OutputFilepath.Substring(0, 2), filesystem, label: volumeLabel); if (res == DriveIO.FormatResult.Success) { ChangeProgress(100, 100, Strings.Formatting); break; } switch (res) { case DriveIO.FormatResult.AccessDenied: MessageBox.Show(Strings.NeedAdmin, "SharpBoot", MessageBoxButtons.OK, MessageBoxIcon.Error); CancelWork(); return; case DriveIO.FormatResult.PartitionTooBig: MessageBox.Show(string.Format(Strings.PartitionTooBig, filesystem), "SharpBoot", MessageBoxButtons.OK, MessageBoxIcon.Error); CancelWork(); return; case DriveIO.FormatResult.UserCancelled: CancelWork(); return; default: if ( MessageBox.Show(Strings.FormatError, "SharpBoot", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Cancel) { CancelWork(); return; } tries++; break; } } }