C# 读取txt文件中的16进制数据

//点击按钮选择文件事件
private
void Decoding_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog();//打开文件 fileDialog.Multiselect = true; fileDialog.Title = "请选择文件"; fileDialog.Filter = "所有文件(*.*)|*.*"; if (fileDialog.ShowDialog()==DialogResult.OK) { string file = fileDialog.FileName;//获取文件地址 byte[] data= File.ReadAllBytes(file);//以byte格式获取文件数据 //将byte格式转16进制 var hex = BitConverter.ToString(data, 0).Replace("-", string.Empty).ToLower(); } }

猜你喜欢

转载自www.cnblogs.com/sjrcwy/p/12924467.html