0

是否有机会将此代码转换为读取 Uint16(16 位)而不是 8 位字节?

Async Sub FillWithHex(rtb As RichTextBox, name As String)

    ' Arbitrary block size. Experiment with different sizes to
    ' see the difference in loading times vs smooth scrolling in richtextbox        
    Dim buff(1000000) As Byte

    Using fs = New FileStream(name, FileMode.Open)
        Using br = New BinaryReader(fs)
            While True
                Dim text = String.Empty
                buff = br.ReadBytes(1000000)
                Await Task.Run(Sub() text = String.Join(" ", buff.
                                Select(Function(b) b.ToString("X2")))).
                                ConfigureAwait(True)
                rtb.AppendText(text)
                If buff.Length < 1000000 Then
                    Exit While
                End If
            End While

        End Using
    End Using
End Sub
4

0 回答 0