我已经四处寻找但找不到解决方案。这个Reading only x number of bytes from file in VB.NET似乎指向了正确的方向,但我不能让它给我需要的HEX信息......
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If (OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
TextBox1.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim filename = TextBox1.Text
Dim arraySize = 5
Dim buffer() As Byte = New Byte(arraySize) {}
Using fs As New System.IO.FileStream(filename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.None)
fs.Read(buffer, 0, buffer.Length)
End Using
'this solves it!
Dim hextottext As String = System.Text.Encoding.UTF8.GetString(buffer)
MsgBox(hextottext)
End Sub
这就是我正在使用的代码 - 当它单步执行时,
fs = System.IO.Filestream
我不明白为什么。
基本上我想读取前6个字节,将它们转换为十六进制的可读文本,这是一个.iso映像文件。
感谢chr功能提示,但我在搜索过程中发现了这一点!