打开.bin文件,它的数据如何在RichTextBox中? [英] Open .bin file, ans how its data in RichTextBox?

查看:104
本文介绍了打开.bin文件,它的数据如何在RichTextBox中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,如何打开.bin文件,  只是一个常见的.bin文件,它显示了微控制器的eeprom的十六进制数据,该数据表示其中的HEX数据。它看起来像AB 24 AB 54 ......所以1byte空间1byte空间1字节等我想打开它,
转换为十六进制字符串能够将它放在richtextbox中。怎么几乎可能?谢谢。

Ok, How is it possible to open a .bin file,  Just a common .bin file which shows a hex data of microcontroller's eeprom, which represets HEX data in it. it looks like AB 24 AB 54...... So 1byte space 1byte space 1 byte etc. I want to open it, convert to hex string to be able put it in richtextbox. How is it nearly possible? Thanks.

推荐答案

  ByteViewer控件是最好最简单的方法, 但是,如果你确实需要或想要使用RichTextBox,那么你可以试试这样的......

 The ByteViewer control would be the best and easiest way to do it,  however if you really need or want to use a RichTextBox then you can try it something like this...

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        RichTextBox1.Font = New Font("Courier New", 9) 'use a fixed width font so that the hex strings are aligned in an equal order
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        RichTextBox1.Text = String.Join("  ", (From b As Byte In IO.File.ReadAllBytes("C:\TestFolder\MyBinFile.bin") Select b.ToString("X2")).ToArray)
    End Sub
End Class


 

 

 

 

 

 如果您使用Castorix31建议的 ByteViewer ,   ;您需要在参考管理器中添加对(System.Design)的引用... 然后,您可以按照Castorix31为您提供的链接中的示例代码向表单添加一个
并使用它。

 If you use the ByteViewer as Castorix31 has suggested,  you will need to add a reference to (System.Design) in the Reference Manager...  Then you can follow the example code at the link that Castorix31 gave you to add one to the form and use it.


这篇关于打开.bin文件,它的数据如何在RichTextBox中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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