3

如何在没有用户交互的情况下使用 VB.NET 将驱动器格式化为 FAT 16 格式

4

1 回答 1

0

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
于 2011-09-14T15:58:47.257 回答