Question Format usb Drive

Tiaan

Member
Joined
Mar 25, 2015
Messages
15
Programming Experience
1-3
I want to format a usb drive. I know its not a good idea to format in code and all that. But i need to minimize the risk of a virus.
When a usb is inserted it picks it up and formats. I have tried with this code, but it keeps telling me drive not found. And i know the drive exists.

VB.NET:
Dim DrvToFormat As String = "I:"
        Dim ret As DialogResult = MessageBox.Show("Are you sure you want to format drive " & DrvToFormat & " ? All data will be lost.", "Warning...", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
        If ret = Windows.Forms.DialogResult.Yes Then
            Shell("Format " & DrvToFormat)
        End If
    End Sub

I have hard coded drive I to test it, but it keeps saying drive not found. Is there any namespace i need to import perhaps when using this?
 
Back
Top