>>>>>>>>>>>读取16进制值<<<<<<<<<<<<<<< 我想使用c#读出一个word文件的16进制表示的数据中,最后一行的16进制值并转换成字符串!我使用FileStream会提示“流不可读取”请问大家有没有什么好的办法。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 16进数 还有行的概念了 byte[] _DocBytes=System.IO.File.ReadAllBytes(@"c:\1.DOC"); string _Text=BitConverter.ToString(_DocBytes);不就全读出来了..然后处理 _DocBytes..或则你当字符串处理_Text就好了.. 先获取数据,再转化public static string UnHex(string hex, string charset) { if (hex == null) throw new ArgumentNullException(""); hex = hex.Replace(",", ""); hex = hex.Replace("\n", ""); hex = hex.Replace("\\", ""); hex = hex.Replace(" ", ""); if (hex.Length % 2 != 0) { hex += "20"; } byte[] bytes = new byte[hex.Length / 2]; for (int i = 0; i < bytes.Length; i++) { try { bytes[i] = byte.Parse(hex.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber); } catch { throw new ArgumentException("", ""); } } System.Text.Encoding chs = System.Text.Encoding.GetEncoding(charset); return chs.GetString(bytes); } 关于If()语句的问题 C# 怎么判断dataGridView1是否有记录 一个锁定Label控件的问题 关于触发器的理解,请帮帮忙谢谢了 C# winform中button鼠标放上去显示的文本在哪里属性设置 net.mail发送邮件在服务器上失败 城优信息技术有限公司北京分公司招聘 新手求助 c#windowsForm 应用程序中的ACESS数据库的添加语句 最小的回文数 关于DataSet中数据的提取! C# 和 VC高手进 一个小问题 请教一下dataview的问题,为什么没有想像中的那么棒
public static string UnHex(string hex, string charset)
{
if (hex == null)
throw new ArgumentNullException("");
hex = hex.Replace(",", "");
hex = hex.Replace("\n", "");
hex = hex.Replace("\\", "");
hex = hex.Replace(" ", "");
if (hex.Length % 2 != 0)
{
hex += "20";
}
byte[] bytes = new byte[hex.Length / 2]; for (int i = 0; i < bytes.Length; i++)
{
try
{
bytes[i] = byte.Parse(hex.Substring(i * 2, 2),
System.Globalization.NumberStyles.HexNumber);
}
catch
{
throw new ArgumentException("", "");
}
}
System.Text.Encoding chs = System.Text.Encoding.GetEncoding(charset);
return chs.GetString(bytes);
}