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

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

+3
source share
1 answer

This will 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
0
source

Source: https://habr.com/ru/post/1732968/


All Articles