save & open file...
-
good morning ..every one ! ok..i wanna to make aprograme that can draw(ellipse,lines,..) but i have aproblems with saving & opening file ..my save code is: FileStream outStream=File.Create(saveFileDialog1.FileName);//To create text file StreamWriter streamWriter=new StreamWriter(outStream); the error...>>(cannot implicity convert type 'System.IO.StreamWritet'to 'System.IO.Stream'. plzz send me back...as fast as u can Regards; :)
-
good morning ..every one ! ok..i wanna to make aprograme that can draw(ellipse,lines,..) but i have aproblems with saving & opening file ..my save code is: FileStream outStream=File.Create(saveFileDialog1.FileName);//To create text file StreamWriter streamWriter=new StreamWriter(outStream); the error...>>(cannot implicity convert type 'System.IO.StreamWritet'to 'System.IO.Stream'. plzz send me back...as fast as u can Regards; :)
What you need to do is convert your shapes into a binary format. You can the deserialize them back into the original shapes. Here's some code to try. //Serialize the shapes before saving FileStream fs = File.Create(strFileName); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, myArray); fs.Close(); //Deserialize the saved shapes FileStream fs = File.Open(strFileName, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); myArray = (ArrayList)bf.Deserialize(fs, null); fs.Close(); Cheers! Richard may your code be error free
-
What you need to do is convert your shapes into a binary format. You can the deserialize them back into the original shapes. Here's some code to try. //Serialize the shapes before saving FileStream fs = File.Create(strFileName); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, myArray); fs.Close(); //Deserialize the saved shapes FileStream fs = File.Open(strFileName, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); myArray = (ArrayList)bf.Deserialize(fs, null); fs.Close(); Cheers! Richard may your code be error free
Dear Richard ..thanks for ur interest man..but finally i wrote acode that can save the file at C Drive as atext but while opening the program can read the data from text..but it cant display it ..this valid while drawing LINES ONLY..my problem is: --------> how can i make the program display the file ( draw the lines..) & how can i do that for ellipse & polygons. this apart of my code : using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Data; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; namespace graphics_practis { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { Point center,radius,v,start,end,a,b; ArrayList arraypoint=new ArrayList(); ArrayList arraylist_points=new ArrayList(); private System.Windows.Forms.Panel panel1; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Button line; private System.Windows.Forms.Button square; private System.Windows.Forms.Button circle; private System.Windows.Forms.Button ellipse; private System.Windows.Forms.Button polygon; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button ok; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.MenuItem menuItem5; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.SaveFileDialog saveFileDialog1; private BinaryFormatter formtter = new BinaryFormatter(); /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // dr = new draw(this.pictureBox1); } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components