BExplorer.Shell.Interop.Shell32.FormatDrive C# (CSharp) Method

FormatDrive() public static method

Format a Drive by given Drive letter
public static FormatDrive ( IntPtr Handle, string DriveLetter ) : uint
Handle System.IntPtr
DriveLetter string The Drive letter
return uint
		public static uint FormatDrive(IntPtr Handle, string DriveLetter) {
			DriveInfo drive = new DriveInfo(DriveLetter);
			byte[] bytes = Encoding.ASCII.GetBytes(drive.Name.ToCharArray());
			uint driveNumber = Convert.ToUInt32(bytes[0] - Encoding.ASCII.GetBytes(new[] { 'A' })[0]);
			uint Result = SHFormatDrive(Handle, driveNumber, SHFormatFlags.SHFMT_ID_DEFAULT,
					 SHFormatOptions.SHFMT_OPT_FULL);
			return Result;
		}