Bin文件转换到十六进制

来源:互联网 发布:淘宝返利网最高返36 编辑:程序博客网 时间:2024/06/06 09:24

            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;        }

从昨晚到现在一直在捣鼓这个问题,后来发现是我想的太复杂了! 简单的几句话就可以了!



0 0