BinaryReader计数 [英] BinaryReader count

查看:113
本文介绍了BinaryReader计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码应该说的足够多,binaryreader计数是错误的..

代码:

The code should say enough, binaryreader counts wrong..

Code:

Dim objBR As BinaryReader
        Dim objFS As FileStream
        Dim objitem As New item

        objFS = New FileStream(File, FileMode.Open, FileAccess.Read)
        objBR = New BinaryReader(objFS)
        objBR.BaseStream.Seek(0, SeekOrigin.Begin)
        RichTextBox1.Text &= objFS.Position & " - " & objFS.Length & vbCrLf
        While objFS.Position < objFS.Length
            objitem = Nothing
            With objitem
                .strHid1 = objBR.ReadChars(12)
                .value0 = objBR.ReadInt32
                .value1 = objBR.ReadInt32
                .strHid2 = objBR.ReadChars(12)
            End With
            RichTextBox1.Text &=  objFS.Position & vbCrLf
        End While
        objBR.Close()
        objFS.Close()




输出:




Output:

0 - 1612
32
65
97
129
161
193
225
257
289
321
353
386
418
450
482
514
546
578
610
642
674
706
739
771
803
835
867
899
931
963
995
1027
1059
1091
1123
1155
1187
1219
1251
1283
1315
1347
1379
1411
1443
1475
1507
1539
1571
1603



所以他这样算:



So he counts like this:

32
33
32
32
32
32
32
32
32
32
32
33
32
32
32
32
32
32
32
32
32
32
33
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32




任何人都可以解释为什么有33个吗?..


现在,我通过变通方法解决了这个问题,直到我知道是什么原因造成的..




Anyone can explain why that 33 is there?..


For now I fixed it using a work around, until I know what is causing it..

While objFS.Position < objFS.Length
            objitem = Nothing
            Dim tst As Integer = objFS.Position
            objitem.strHid1 = objBR.ReadChars(12)
            objitem.value0 = objBR.ReadInt32
            objitem.value1 = objBR.ReadInt32
            objitem.strHid2 = objBR.ReadChars(12)
            RichTextBox1.Text &= objFS.Position & vbCrLf
            If objFS.Position - tst <> 32 Then
                objFS.Position = tst + 32
            End If
        End While

推荐答案

看看您的数据-它有什么奇怪的地方吗?
使用十六进制查看器(大多数程序员编辑器都有一个).如果您还没有,请d/l PsPad [ ^ ]它是免费的,还不错.
Look at your data - is there anything odd about it?
Use a hex viewer (most programmers editors have one). If you haven''t got one, d/l PsPad[^] it''s free and pretty good.


我什么也没看到关于您的代码很奇怪.您是否已在调试器下运行它?
I don''t see anything weird about your code. Have you run it under the debugger?


这篇关于BinaryReader计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆