home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic .NET - Read Less - Learn More / Visual_Basic.NET_Read_Less_Learn_More_Richard_Bowman_Visual_2002.iso / Resources / Code / Ch13-RecoverFromError / Form1.vb < prev   
Text File  |  2001-09-01  |  2KB  |  61 lines

  1. Public Class Form1
  2.     Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6.     Public Sub New()
  7.         MyBase.New()
  8.  
  9.         'This call is required by the Windows Form Designer.
  10.         InitializeComponent()
  11.  
  12.         'Add any initialization after the InitializeComponent() call
  13.  
  14.     End Sub
  15.  
  16.     'Form overrides dispose to clean up the component list.
  17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18.         If disposing Then
  19.             If Not (components Is Nothing) Then
  20.                 components.Dispose()
  21.             End If
  22.         End If
  23.         MyBase.Dispose(disposing)
  24.     End Sub
  25.  
  26.     'Required by the Windows Form Designer
  27.     Private components As System.ComponentModel.Container
  28.  
  29.     'NOTE: The following procedure is required by the Windows Form Designer
  30.     'It can be modified using the Windows Form Designer.  
  31.     'Do not modify it using the code editor.
  32.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  33.         '
  34.         'Form1
  35.         '
  36.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  37.         Me.ClientSize = New System.Drawing.Size(292, 273)
  38.         Me.Name = "Form1"
  39.         Me.Text = "Form1"
  40.  
  41.     End Sub
  42.  
  43. #End Region
  44.  
  45.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  46.         Dim file As IO.FileStream
  47.         Try
  48.             file = New IO.FileStream("c:\test.txt", _
  49.                 IO.FileMode.Open, IO.FileAccess.Read)
  50.         Catch ex As Exception
  51.             MessageBox.Show("Recreating configuration file.")
  52.             IO.File.Create("c:\test.txt")
  53.             file = New IO.FileStream("c:\test.txt", _
  54.                 IO.FileMode.Open, IO.FileAccess.Read)
  55.         Finally
  56.             Dim txt As String = _
  57.                 (New IO.StreamReader(file)).ReadToEnd()
  58.         End Try
  59.     End Sub
  60. End Class
  61.