Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nums(10) As Integer
Dim i As Integer
For i = 0 To 10
nums(i) = Int(Rnd() * 500) + 100
Next
Dim sfFormatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim fStream As New FileStream(Application.StartupPath & "/test.txt", FileMode.Create)
sfFormatter.Serialize(fStream, nums)
fStream.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim nums(10) As Integer
Dim fStream As New FileStream(Application.StartupPath & "/test.txt", FileMode.Open)
Dim sfFormatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
nums = sfFormatter.Deserialize(fStream)
fStream.Close()
Dim i As Integer
For i = 0 To 9
Console.WriteLine(nums(i))
Next
End Sub