Dim ReadBinFile As FileStream Dim Strings As String Dim Numbers As Decimal ReadBinFile = New IO.FileStream("C:\temp\ass1\binfile.dat", IO.FileMode.Open) Dim ReadBinary As New BinaryReader(ReadBinFile) Do While ReadBinary.PeekChar <> -1 Strings = ReadBinary.ReadString() Numbers = ReadBinary.ReadDecimal() MsgBox(Strings) MsgBox(Numbers) Dim rvBW As New IO.BinaryWriter(New IO.FileStream("C:\temp\ass1\readbinfile.txt", IO.FileMode.Create)) rvBW.Write(Strings) rvBW.Write(Numbers) rvBW.Close() Loop ReadBinFile.Close()
The code just doesn't work properly..
1. The loop doesn't stop, and it gives me "Unable to read beyond the end of the stream" Error..
2. The output isn't accurate, apart from a few random correct strings and numbers..
3. After the loop is fixed, how can i save the data to an Array or write it to a text file?. Can the be saved line by line so that the output file has the same number of lines?
4. As you can see in the code, I've tried writing data in a file, but it doesn't work.. Messagebox does show some data (even though it's not accurate), the file however doesn't contain any data..