操作二进制文件

1.将数据存为二进制文件

var filePath = AppDomain.CurrentDomain.BaseDirectory + "TableGly.bin";
using (var s = File.Create(filePath))
{
var bin = new BinaryFormatter();
bin.Serialize(s, glylist);
}

 

2.将二进制文件都出来

 

var filePath = AppDomain.CurrentDomain.BaseDirectory + "TableGly.bin";

using (var s = File.Open(path, FileMode.Open))
{
var bin = new BinaryFormatter();
var list = bin.Deserialize(s) as List<long>;
if (list != null)
{
var str = string.Join(",", list3.ToArray());
}
}

posted @ 2015-11-25 16:56  逍遥帝君  阅读(199)  评论(0编辑  收藏  举报