How to programatically format an SD card with FAT16?

前端 未结 6 1414
旧时难觅i
旧时难觅i 2020-12-10 20:47

I\'d like to initialize an SD card with FAT16 file system. Assuming that I have my SD reader on drive G:, how I can easily format it to FAT16 ?

UPDATE:

6条回答
  •  清歌不尽
    2020-12-10 21:19

    If you just want a quick format of the existing format type, no need to specify anything. Let the system use defaults.

    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = "format.com";
    startInfo.Arguments = $"{drive} /V:{volumeName} /Q"
    startInfo.UseShellExecute = false;
    startInfo.CreateNoWindow = true;
    startInfo.RedirectStandardOutput = true;
    startInfo.RedirectStandardInput = true;
    Process.Start(startInfo);
    
    //because there will be a prompt, this input by passes that prompt.
    StreamWriter processInputStream = p.StandardInput;
    processInputStream.Write("\r\n");
    

    At the command prompt it's like this:

    format.com H: /V:MyVolumeName /Q
    

提交回复
热议问题