我正在开发一个程序,WPF
需要在文件中写入和读取shapse
(矩形,椭圆,...)并读取它们。
有什么办法,或者我必须写它的规格,比如宽度、高度……加载它们?任何想法?
我用过:
Stream stream = File.Open("mehdi.txt", FileMode.Create);
BinaryFormatter bFormatter = new BinaryFormatter();
ArrayList a = new ArrayList();
a.Add(shapelist); //shapelist is arraylist
bFormatter.Serialize(stream, a);
stream.Close();
但此代码有以下错误:
Type 'System.Windows.Shapes.Rectangle' in Assembly 'PresentationFramework, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.