
Patrick B. answered 08/10/20
Math and computer tutor/teacher
Null terminator or End of file marker possibly getting written to file...
Integers are 2 bytes at least...
try using a short integer or a byte
the following code works, in VB.net
'***********************************************************************************
Imports System.IO
Module Module1
Sub Main()
Dim bw As BinaryWriter
Dim i As Byte = 25
'creates the file
Try
bw = New BinaryWriter(New FileStream("c:\users\pdiru\desktop\mydata.dat", FileMode.Create))
Catch e As IOException
Console.WriteLine(e.Message + "\n Cannot create file.")
Return
End Try
'writing into the file
Try
bw.Write(i)
Catch e As IOException
Console.WriteLine(e.Message + "\n Cannot write to file.")
Return
End Try
bw.Close()
Console.ReadKey()
End Sub
End Module