How to format drive in FAT 16 format using VB.NET without user interaction

走远了吗. 提交于 2019-12-14 03:51:13

问题


How to format drive in FAT 16 format using VB.NET without user interaction


回答1:


That would be the VB.NET translation of this C# answer to a similar question :

Dim allDrives As DriveInfo() = DriveInfo.GetDrives()
For Each d As DriveInfo In allDrives
    If d.IsReady AndAlso (d.DriveType = DriveType.Removable) Then
        Dim startInfo As New ProcessStartInfo()
        startInfo.FileName = "format.com"
        startInfo.Arguments = "/fs:FAT /v:MyVolume /q " & d.Name.Remove(2)
        startInfo.UseShellExecute = False
        startInfo.CreateNoWindow = True
        startInfo.RedirectStandardOutput = True
        startInfo.RedirectStandardInput = True

        Dim p As Process = Process.Start(startInfo)

        Dim processInputStream As StreamWriter = p.StandardInput
        processInputStream.Write(vbCr & vbLf)


        p.WaitForExit()
    End If
Next


来源:https://stackoverflow.com/questions/2271246/how-to-format-drive-in-fat-16-format-using-vb-net-without-user-interaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!