2个回答
展开全部
看什么格式了。这个定义的保存CAD
Stream s = File.Open(filePath, FileMode.Create,FileAccess.ReadWrite);
BinaryFormatter b = new BinaryFormatter();
for (int i = 0; i < this.getCurrentShapes().Count; i++)
{
b.Serialize(s,this.getCurrentShapes()[i]);
}
s.Close();
这个是二进制数据流。
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "序列化文件 (*.bin)|*.bin";
if (sfd.ShowDialog() == DialogResult.OK)
{
FileStream fs = new FileStream(sfd.FileName , FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, _guiLocations);
fs.Close();
FileStream fs1 = new FileStream(sfd.FileName+"Conn", FileMode.Create);
BinaryFormatter bf1 = new BinaryFormatter();
bf1.Serialize(fs1, _connections);
fs1.Close();
}
this.Activate();
PaintGui();
我用到的就这两种,不过别的和这个方法大同小异吧!
Stream s = File.Open(filePath, FileMode.Create,FileAccess.ReadWrite);
BinaryFormatter b = new BinaryFormatter();
for (int i = 0; i < this.getCurrentShapes().Count; i++)
{
b.Serialize(s,this.getCurrentShapes()[i]);
}
s.Close();
这个是二进制数据流。
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "序列化文件 (*.bin)|*.bin";
if (sfd.ShowDialog() == DialogResult.OK)
{
FileStream fs = new FileStream(sfd.FileName , FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, _guiLocations);
fs.Close();
FileStream fs1 = new FileStream(sfd.FileName+"Conn", FileMode.Create);
BinaryFormatter bf1 = new BinaryFormatter();
bf1.Serialize(fs1, _connections);
fs1.Close();
}
this.Activate();
PaintGui();
我用到的就这两种,不过别的和这个方法大同小异吧!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询