2
(Debugger).
Debug. Exceptions ( 81)
.
.
81
Break into the debugger,
.
Continue,
.
Use parent setting,
.
File System.
,
:
Button1 Label1. :
Private
Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim fw As New FileWork
fw.FileWorkMy()
End Sub
Private Sub
Label1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Label1.Click
Label1.Text =
"InFile = ""c:SomeInFile.bin"" OutFile
=""c:someOutFile.Bin"" "
End Sub
Add -
Add Class,
82
FileWork.
vb.
82
:
Option
Explicit On
Imports
System.Windows.Forms
Imports
System.IO
Imports
System.Diagnostics
Imports
System.Threading
Public
Class FileWork
Sub
FileWorkMy()
Dim OutFile As String
Dim InFile As String
InFile =
"c:SomeInFile.bin"
OutFile =
"c:someOutFile.Bin"
Dim outf As
System.IO.File
Dim inf As
System.IO.File
Dim x As Integer
Dim aRetVal As Integer
' - streams - input -
output
Dim myInstream As
System.IO.FileStream
Dim myOutstream As
System.IO.FileStream
Dim aFoo(100) As
System.Byte '
For x = 1 To 99
aFoo(x) = x
Next
Try
myOutstream =
outf.OpenWrite(OutFile) '"c:someOutFile.bin"
myOutstream.Flush()
For x = 1 To 11
myOutstream.Write(aFoo, 0, 10)
Next
myOutstream.Close()
myInstream =
inf.OpenRead(OutFile) '"c:someInFile.bin"
aRetVal =
myInstream.Read(aFoo, 0, 10) ' 10
MessageBox.Show(aRetVal)
Catch IOExcep As
IO.IOException
' .
`error message
MessageBox.Show(IOExcep.Message)
Finally
myInstream.Close() ' -
files
End Try
End Sub
End Class

83 File System