下面是.bin文件里的东西
//项目 起始位置 字节长度 备注
//文件完整性标志字 0 1 0不完整,0x5a 完整
//烟尘采样文件标志字 1 2 1:0xa5; 2:0x02 //采样文件标志字
//采样文件数据类型写标志字 3 1 0x01 只有烟气数据;0x02:即有烟气数据也有烟尘获油烟数据
//项目 起始位置 字节长度 备注
//文件完整性标志字 0 1 0不完整,0x5a 完整
//烟尘采样文件标志字 1 2 1:0xa5; 2:0x02 //采样文件标志字
//采样文件数据类型写标志字 3 1 0x01 只有烟气数据;0x02:即有烟气数据也有烟尘获油烟数据
05. StringBuilder b = new StringBuilder();
06. using (FileStream fs = new FileStream(path, FileMode.Open))
07. {
08. using (StreamReader sr = new StreamReader(fs))
09. {
10. while (!sr.EndOfStream)
11. {
12. string sLine = sr.ReadLine();
13. if (sLine.Length < 1)
14. {
15. continue;
16. }
17. string sRecordKbn = sLine.Substring(0,8);//截取的数据
18.
19. b.Append(sRecordKbn+"/r/n");
20. }
21. }
22. }
一行一行的读取
读取文本文件一样的。
就是把一个.bin文件的内容读取出来,把数据放入数据库,可我不知道怎么取数据
BinaryReader br = new BinaryReader(file);然后根据你的bin文件的具体内容,调用br.ReadBytes()或者br.ReadString()等方法