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 file as atext...

save file as atext...

Scheduled Pinned Locked Moved Graphics
graphicsdockerjsonhelp
9 Posts 2 Posters 6 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

    i wanna to make aprogram that can draw (ellips , line,..) but i have problems with the save & open ..thats apart of the code: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; 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 { 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 BinaryFormatter formtter = new BinaryFormatter(); private FileStream str_reader; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.SaveFileDialog saveFileDialog1; private System.Windows.Forms.OpenFileDialog openFileDialog1; /// /// 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); } static void Main() { Application.Run(new Form1()); } private void menuItem4_Click(object sender, System.EventArgs e) { //saving FileStream outStream=File.Create(saveFileDialog1.FileName);//To create text file Stream streamWriter=new StreamWriter(outStream); } private void menuItem3_Click(object sender, System.EventArgs e) { //opening FileStream outStream=File.Create(saveFileDialog1.FileName);//To create text file StreamWriter streamWriter=new StreamWriter(outStream); } the error...>>(cannot implicity convert type '

    D 1 Reply Last reply
    0
    • M mr jets

      i wanna to make aprogram that can draw (ellips , line,..) but i have problems with the save & open ..thats apart of the code: using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; 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 { 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 BinaryFormatter formtter = new BinaryFormatter(); private FileStream str_reader; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.SaveFileDialog saveFileDialog1; private System.Windows.Forms.OpenFileDialog openFileDialog1; /// /// 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); } static void Main() { Application.Run(new Form1()); } private void menuItem4_Click(object sender, System.EventArgs e) { //saving FileStream outStream=File.Create(saveFileDialog1.FileName);//To create text file Stream streamWriter=new StreamWriter(outStream); } private void menuItem3_Click(object sender, System.EventArgs e) { //opening FileStream outStream=File.Create(saveFileDialog1.FileName);//To create text file StreamWriter streamWriter=new StreamWriter(outStream); } the error...>>(cannot implicity convert type '

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Seriously, stop this project and go pickup a book on beginning C#. You've got some serious "C# and .NET Framework 101" issues to contend with. Just getting something as simple as a StreamWriter to work is giving to fits. Actually doing some drawing is about 10 times more difficult. Besides, how are you going to save you're image? Are you really going to try to write binary data to a text file??

      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      M 2 Replies Last reply
      0
      • D Dave Kreskowiak

        Seriously, stop this project and go pickup a book on beginning C#. You've got some serious "C# and .NET Framework 101" issues to contend with. Just getting something as simple as a StreamWriter to work is giving to fits. Actually doing some drawing is about 10 times more difficult. Besides, how are you going to save you're image? Are you really going to try to write binary data to a text file??

        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

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

        Dave Kreskowiak :how are you going to save you're image? Are you really going to try to write binary data to a text file??..yes . ok look bro i have changed my saving code and used StreamWriter but its doesnt write binary data to a text file !!!! so when i opened the file the program doesnt display and of my drwaing ( line,ellipse,...) PLZZZZ..MR DAVE..SEND ME BACK AS SOON AS U CAN..!! Regards;:)

        D 1 Reply Last reply
        0
        • D Dave Kreskowiak

          Seriously, stop this project and go pickup a book on beginning C#. You've got some serious "C# and .NET Framework 101" issues to contend with. Just getting something as simple as a StreamWriter to work is giving to fits. Actually doing some drawing is about 10 times more difficult. Besides, how are you going to save you're image? Are you really going to try to write binary data to a text file??

          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

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

          my new save code is : System.IO.FileStream fs = new System.IO.FileStream("c:\\testing.txt", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite); // create a stream writer System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, System.Text.Encoding.ASCII); // write to file (buffer), where textbox1 is your text box sw.Write("text"); // flush buffer (so the text really goes into the file) sw.Flush(); // close stream writer and file sw.Close(); fs.Close();

          1 Reply Last reply
          0
          • M mr jets

            Dave Kreskowiak :how are you going to save you're image? Are you really going to try to write binary data to a text file??..yes . ok look bro i have changed my saving code and used StreamWriter but its doesnt write binary data to a text file !!!! so when i opened the file the program doesnt display and of my drwaing ( line,ellipse,...) PLZZZZ..MR DAVE..SEND ME BACK AS SOON AS U CAN..!! Regards;:)

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            mr jets wrote:

            Are you really going to try to write binary data to a text file??..yes

            Good luck with that! BTW, the code you posted doesn't write ANYTHING to the file. All it does is open it. It doesn't even close the file when it's "done". Seriously, you're missing a ton of basic knowledge you MUST have to build applications with.

            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            M 1 Reply Last reply
            0
            • D Dave Kreskowiak

              mr jets wrote:

              Are you really going to try to write binary data to a text file??..yes

              Good luck with that! BTW, the code you posted doesn't write ANYTHING to the file. All it does is open it. It doesn't even close the file when it's "done". Seriously, you're missing a ton of basic knowledge you MUST have to build applications with.

              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

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

              thanks for ur effort mr Dave..god bless u bro..but remember i said iam TRYING to save the pic by entering binary data to text ..but i couldnt ..:confused:..i just can creat atext but it doesnt recieve any values...:doh: comone ..i need ur help mr Dave !!

              D 1 Reply Last reply
              0
              • M mr jets

                thanks for ur effort mr Dave..god bless u bro..but remember i said iam TRYING to save the pic by entering binary data to text ..but i couldnt ..:confused:..i just can creat atext but it doesnt recieve any values...:doh: comone ..i need ur help mr Dave !!

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                Well, I would start by never saving an image as a text file. Next, have you looked as the Save[^] method on the Bitmap class.

                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                M 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  Well, I would start by never saving an image as a text file. Next, have you looked as the Save[^] method on the Bitmap class.

                  Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                       2006, 2007

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

                  iam so greatfull for ur help mr Dave ..who said i wanna to save image ..okie i just wanna to save my drawings in picturebox (lines,ellips,...) so i can display it again ..like the Paint.. iam waiting ur reply... Regards ;:zzz:

                  D 1 Reply Last reply
                  0
                  • M mr jets

                    iam so greatfull for ur help mr Dave ..who said i wanna to save image ..okie i just wanna to save my drawings in picturebox (lines,ellips,...) so i can display it again ..like the Paint.. iam waiting ur reply... Regards ;:zzz:

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    If you can't get the Stream classes down, this is WAY over your head. Go back to the basics. There's nothing that does this for you. You have to keep track of the mouse position, where the mouse buttons were held down and where it is now, drawing, calculating the circle, arc, whatever, drawing the new graphic to your bitmap, then updating the image displayed in the PictureBox, ...

                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007

                    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