0

16 バイト構造に格納されたデータで構成されるバイナリ ファイル "blahblah.dat" があります。ファイルの各行の長さは 16 バイトです。

このファイルを 1 行ずつ読み込んで、バイナリ データを 10 進数に変換し、テキスト ボックスに表示したいと考えています。

探してみたのですが、適当なものが見つからないようです。


このコードの使用:

Using reader As New BinaryReader(File.Open("C:\Users\User\Desktop\test.dat", FileMode.Open))
        ' Loop through length of file.
        Dim pos As Integer = 0
        Dim length As Integer = reader.BaseStream.Length
        While pos < 1024
            ' Read the integer.
            For i = 0 To 15
                Dim value As Decimal = reader.ReadByte
                ' Write to screen.
                Console.WriteLine(value)
                TextBox1.Text = TextBox1.Text & value & ","
                pos += 1
            Next
            ' Add length of decimal in bytes to position.
            TextBox1.Text = TextBox1.Text & vbCrLf
        End While
    End Using

私はこれらの結果を得ました(これは私が正しいと思うものです-後で確認します):

0,0,128,32,0,0,0,0,2,162,36,18,7,8,3,11,
0,3,128,32,0,0,0,0,1,138,37,18,7,8,3,11,
0,51,128,40,0,0,0,0,0,113,38,18,7,8,3,11,
0,51,128,40,0,0,0,0,3,66,38,18,7,8,3,11,
0,51,128,40,0,0,0,0,2,42,39,18,7,8,3,11,
0,51,130,40,0,0,0,0,1,18,40,18,7,8,3,11,
0,51,130,40,0,0,0,0,3,226,40,18,7,8,3,11,
0,51,130,40,0,0,0,0,2,202,41,18,7,8,3,11,
0,51,130,40,0,0,0,0,1,178,42,18,7,8,3,11,
0,51,130,40,0,0,0,0,0,154,43,18,7,8,3,11,
0,51,130,40,0,0,0,0,3,106,43,18,7,8,3,11,
0,51,130,40,0,0,0,0,2,82,44,18,7,8,3,11,
0,51,130,40,0,0,0,0,1,58,45,18,7,8,3,11,
0,51,130,40,0,0,0,0,0,34,46,18,7,8,3,11,
0,51,130,40,0,0,0,0,2,242,46,18,7,8,3,11,
0,51,130,40,0,0,0,0,1,218,47,18,7,8,3,11,
0,51,130,40,0,0,0,0,0,195,48,18,7,8,3,11,
0,51,130,40,0,0,0,0,3,146,48,18,7,8,3,11,
0,51,130,40,0,0,0,0,2,122,49,18,7,8,3,11,
0,51,130,40,0,0,0,0,1,98,50,18,7,8,3,11,
0,51,130,40,0,0,0,0,0,74,51,18,7,8,3,11,
0,51,130,40,0,0,0,0,3,26,51,18,7,8,3,11,
0,51,130,40,0,0,0,0,2,3,52,18,7,8,3,11,
0,51,130,40,0,0,0,0,0,234,53,18,7,8,3,11,
0,51,130,40,0,0,0,0,3,187,53,18,7,8,3,11,
0,51,130,40,0,0,0,0,2,163,54,18,7,8,3,11,
0,51,130,40,0,0,0,0,1,139,55,18,7,8,3,11,
0,51,130,40,0,0,0,0,0,115,56,18,7,8,3,11,
0,51,130,40,0,0,0,0,3,67,56,18,7,8,3,11,
0,51,130,40,0,0,0,0,2,43,57,18,7,8,3,11,
0,51,130,40,0,0,0,0,1,19,58,18,7,8,3,11,
0,51,130,40,0,0,0,0,3,227,58,18,7,8,3,11,
0,51,130,40,0,0,0,0,2,203,59,18,7,8,3,11,
0,51,130,40,0,0,0,0,1,179,0,19,7,8,3,11,
0,51,130,40,0,0,0,0,0,156,1,19,7,8,3,11,
0,51,130,40,0,0,0,0,3,108,1,19,7,8,3,11,
0,51,130,40,0,0,0,0,2,84,2,19,7,8,3,11,
0,0,128,32,0,0,0,0,3,172,9,19,7,8,3,11,
15,0,128,32,0,0,0,0,1,238,10,19,7,8,3,11,
15,0,128,0,0,0,0,0,0,44,11,19,7,8,3,11,
15,51,128,8,0,0,0,0,2,80,11,19,7,8,3,11,
15,51,128,8,0,0,0,0,0,151,12,19,7,8,3,11,
15,51,128,8,0,0,0,0,2,197,12,19,7,8,3,11,
15,51,128,8,0,0,0,0,1,10,13,19,7,8,3,11,
15,51,128,8,0,0,0,0,3,57,13,19,7,8,3,11,
15,51,128,8,0,0,0,0,1,140,14,19,7,8,3,11,
15,51,128,8,0,0,0,0,3,192,14,19,7,8,3,11,
15,51,128,8,0,0,0,0,2,13,15,19,7,8,3,11,
15,51,128,8,0,0,0,0,0,95,16,19,7,8,3,11,
15,51,128,8,0,0,0,0,2,145,16,19,7,8,3,11,
15,51,128,8,0,0,0,0,0,225,17,19,7,8,3,11,
15,51,128,8,0,0,0,0,3,26,17,19,7,8,3,11,
15,51,128,8,0,0,0,0,1,104,18,19,7,8,3,11,
15,51,128,8,0,0,0,0,3,152,18,19,7,8,3,11,
15,51,128,8,0,0,0,0,1,229,19,19,7,8,3,11,
15,51,128,8,0,0,0,0,0,44,20,19,7,8,3,11,
15,51,128,8,0,0,0,0,2,88,20,19,7,8,3,11,
15,51,128,8,0,0,0,0,0,159,21,19,7,8,3,11,
15,51,128,8,0,0,0,0,2,213,21,19,7,8,3,11,
15,51,128,8,0,0,0,0,1,30,22,19,7,8,3,11,
15,51,128,8,0,0,0,0,3,75,22,19,7,8,3,11,
15,51,128,8,0,0,0,0,1,145,23,19,7,8,3,11,
15,51,128,8,0,0,0,0,3,193,23,19,7,8,3,11,
15,51,128,8,0,0,0,0,2,12,24,19,7,8,3,11,

それがデータを取得する最良の方法でしょうか、それともコードを整理する方法はありますか?

4

1 に答える 1