using System.Runtime.Serialization.Formatters.Binary
读取数据
public string[] duqu(string sjname)
{
FileStream fs = new FileStream(sjname+".bin", FileMode.Open);
//二进制方式
BinaryFormatter bf = new BinaryFormatter();
//序列化存储对象
string[] shuju = (string[])bf.Deserialize(fs);
//关闭流
fs.Close();
return shuju;
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
写入数据
public void xiru(string binname,string[] xirustring)
{
//定义文件流
FileStream fs = new FileStream(binname +".bin", FileMode.Create);
//二进制方式
BinaryFormatter bf = new BinaryFormatter();
//序列化存储对象
bf.Serialize(fs, xirustring );
//关闭流
fs.Close();
}
List
List
foreach (var item in System.IO.File.ReadAllLines("1.txt"))
{
list.Add(item.Split(' '));
}
list.ToArray(); 返回的对象就是你要的数组矩阵