Click to See Complete Forum and Search --> : error handling in vb.net


mtc
May 22nd, 2002, 11:51 AM
I am trying to capture errors specific to the floppy drive. I want to capture the error number for floppy not in drive, disk write protected and file not found, any help appreciated Thanks

Iouri
May 22nd, 2002, 01:40 PM
Here is how to check if floppy is in

Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "
#End Region
Dim Retries As Short = 0

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Try
PictureBox1.Image = System.Drawing.Bitmap.FromFile("a:\fileopen.bmp")
Catch
Retries += 1
If Retries <= 2 Then
MsgBox("Please insert the disk in drive A!")
Else
MsgBox("File Load feature disabled")
Button1.Enabled = False
End If
End Try

End Sub
End Class