基本信息
源码名称:hex转bin的程序
源码大小:0.04M
文件格式:.rar
开发语言:C#
更新时间:2020-09-05
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
hex转bin的程序, 支持大于64K的hex, 网上下载的Hex2Bin不支持64k. 包含工程文件, 简单包装即可生成一个Hex2Bin的小程序
String szLine = "";
String szHex = "";
if (szHexPath == "")
{
MessageBox.Show("请选择需要转换的目标文件! ", "错误");
return;
}
StreamReader HexReader = new StreamReader(szHexPath);
while (true)
{
szLine = HexReader.ReadLine(); //读取一行数据
if (szLine == null) //读完所有行
{
break;
}
if (szLine.Substring(0, 1) == ":") //判断第1字符是否是:
{
if (szLine.Substring(1, 8) == "00000001")//数据结束
{
break;
}
szHex = szLine.Substring(9, szLine.Length - 11); //读取有效字符
}
}
HexReader.Close(); //关闭目标文件
Int32 i;
Int32 j = 0;
Int32 Length = szHex.Length;
byte[] szBin = new byte[Length];
pbConvert.Maximum = Length / 2;
for (i = 0; i < Length; i = 2) //两字符合并成一个16进制字节
{
szBin[j] = (byte)Int16.Parse(szHex.Substring(i, 2), NumberStyles.HexNumber);
j ;
pbConvert.Increment(i);
}
if (szBinPath == "")
{
szBinPath = Path.ChangeExtension(szHexPath, "bin");
tbBinPath.Text = szBinPath;
}
FileStream fBin = new FileStream(szBinPath, FileMode.Create); //创建文件BIN文件
BinaryWriter BinWrite = new BinaryWriter(fBin); //二进制方式打开文件
BinWrite.Write(szBin, 0, Length); //写入数据
BinWrite.Flush();//释放缓存
BinWrite.Close();//关闭文件
MessageBox.Show("文件转换完成! ", "提示");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
hex转bin的程序, 支持大于64K的hex, 网上下载的Hex2Bin不支持64k. 包含工程文件, 简单包装即可生成一个Hex2Bin的小程序
String szLine = "";
String szHex = "";
if (szHexPath == "")
{
MessageBox.Show("请选择需要转换的目标文件! ", "错误");
return;
}
StreamReader HexReader = new StreamReader(szHexPath);
while (true)
{
szLine = HexReader.ReadLine(); //读取一行数据
if (szLine == null) //读完所有行
{
break;
}
if (szLine.Substring(0, 1) == ":") //判断第1字符是否是:
{
if (szLine.Substring(1, 8) == "00000001")//数据结束
{
break;
}
szHex = szLine.Substring(9, szLine.Length - 11); //读取有效字符
}
}
HexReader.Close(); //关闭目标文件
Int32 i;
Int32 j = 0;
Int32 Length = szHex.Length;
byte[] szBin = new byte[Length];
pbConvert.Maximum = Length / 2;
for (i = 0; i < Length; i = 2) //两字符合并成一个16进制字节
{
szBin[j] = (byte)Int16.Parse(szHex.Substring(i, 2), NumberStyles.HexNumber);
j ;
pbConvert.Increment(i);
}
if (szBinPath == "")
{
szBinPath = Path.ChangeExtension(szHexPath, "bin");
tbBinPath.Text = szBinPath;
}
FileStream fBin = new FileStream(szBinPath, FileMode.Create); //创建文件BIN文件
BinaryWriter BinWrite = new BinaryWriter(fBin); //二进制方式打开文件
BinWrite.Write(szBin, 0, Length); //写入数据
BinWrite.Flush();//释放缓存
BinWrite.Close();//关闭文件
MessageBox.Show("文件转换完成! ", "提示");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}