日期:2014-05-17 浏览次数:20803 次
//把文件读进流,保存到集合里面
IList<MemoryStream> list = new List<MemoryStream>();
MemoryStream Ms1 = new MemoryStream(File.ReadAllBytes("D:\\1.dat"));
MemoryStream Ms2 = new MemoryStream(File.ReadAllBytes("D:\\2.dat"));
list.Add(Ms1);
list.Add(Ms2);
//序列化保存到本地
FileStream fs = new FileStream("D:\\3.dat", FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, list);
fs.Close();
//反序列化拿到文件集合
FileStream fs = new FileStream("D:\\3.dat", FileMode.Open);
BinaryFormatter bf =new BinaryFormatter();
IList<MemoryStream> Ms = (IList<MemoryStream>)bf.Deserialize(fs);