我正在创建一个表单应用程序,在这个应用程序中我让用户绘制矩形,三角形,六边形等。我想将这些图形保存在文件中,我想在打开程序时使用它们。我的意思是使用它们像nirmal图形。我正在选择并更改我想要的绘制对象的颜色。如果我将此文件导入我的应用程序,则能够更改它的颜色
答案 0 :(得分:-1)
像这样。
// write
BinaryWriter Writer = new BinaryWriter(File.Open(FileName, FileMode.Create));;
Writer.Write(this.Point.X); Writer.Write(this.Point.Y); Writer.Write(this.Point.Z);
Writer.Write(this.Point.X); Writer.Write(this.Point.Y); Writer.Write(this.Point.Z);
Writer.Write(this.Point.X); Writer.Write(this.Point.Y); Writer.Write(this.Point.Z);
Writer.Write(this.Point.X); Writer.Write(this.Point.Y); Writer.Write(this.Point.Z);
Writer.Flush();
Writer.Close();
// read
BinaryReader Reader = new BinaryReader(File.Open(FileName, FileMode.Open));
this.Point.X = Reader.ReadDouble(); this.Point.Y = Reader.ReadDouble(); this.Point.Z = Reader.ReadDouble();
this.Point.X = Reader.ReadDouble(); this.Point.Y = Reader.ReadDouble(); this.Point.Z = Reader.ReadDouble();
this.Point.X = Reader.ReadDouble(); this.Point.Y = Reader.ReadDouble(); this.Point.Z = Reader.ReadDouble();
this.Point.X = Reader.ReadDouble(); this.Point.Y = Reader.ReadDouble(); this.Point.Z = Reader.ReadDouble();
Reader.Close();