求将二进制文件转化的代码
有一powprod.$25文件见附件,是内容为数据的二进制文件,想把它转化为float的txt文件(powprod.txt),8个数据一行,求代码?
powprod.rar
(166.32 KB)
class program { public static void Main(string[] args) { FileStream fs = new FileStream("I:\\powprod.$25", FileMode.Open); byte[] by = new byte[fs.Length]; fs.Read(by, 0, (int)fs.Length); fs.Close(); int i = 0; while (i <= by.Length - 1) { float sh = BitConverter.ToSingle(by, i); Console.WriteLine(sh.ToString("r")); i += 4; } Console.Read(); } }