Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. save & open file...

save & open file...

Scheduled Pinned Locked Moved Graphics
help
3 Posts 2 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mr jets
    wrote on last edited by
    #1

    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; :)

    R 1 Reply Last reply
    0
    • M mr jets

      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; :)

      R Offline
      R Offline
      Richard Blythe
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • R Richard Blythe

        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

        M Offline
        M Offline
        mr jets
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups