2

我正在尝试读取二进制文件的第一个字,它告诉我该文件包含多少个步骤。在 VB.net 中处理二进制数据时,我完全是个新手

最好的办法是什么?我实际上只需要读取文件第一个单词的值——我不需要对它做更多的事情。

我找到了这段代码,但它只返回一个空字符串:

Imports System.IO
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim readStream As FileStream
        Dim msg As String
        Try
            readStream = New FileStream("C:\FreeStyler\Chases\Quadzilla - RedGreenBlue - Shrinking Squares (Pattern 23) - Static.chb", FileMode.Open)
            Dim readBinary As New BinaryReader(readStream)
            msg = readBinary.ReadString()
            MsgBox(msg)
            readStream.Close()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

End Class

提前致谢 ...

4

1 回答 1

0

尝试这个 ...

readStream = New FileStream("C:\FreeStyler\Chases\Quadzilla - RedGreenBlue - Shrinking Squares (Pattern 23) - Static.chb", FileMode.Open)
Dim readBinary As New BinaryReader(readStream)
msg  as Integer = readBinary.ReadInt32()
MsgBox(msg.ToString)
readStream.Close()
于 2013-06-07T03:50:54.133 回答