byte[] BytesFile = ConvertToBinary(StrFileLocation);
string Str_Result = string.Empty; //汇总结果
for (int i = 0; i < BytesFile.Length; i++)
{
Str_Result += Convert.ToString(BytesFile[i], 16).ToUpper();
}
this.Txt_UpgradeLog.Text = Str_Result;
/// <summary>
/// 文件转换到二进制
/// </summary>
/// <param name="Path"></param>
/// <returns></returns>
public static byte[] ConvertToBinary(string Path)
{
FileStream stream = new FileInfo(Path).OpenRead();
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
return buffer;
}
从昨晚到现在一直在捣鼓这个问题,后来发现是我想的太复杂了! 简单的几句话就可以了!