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. C#
  4. Serialization (save and loading)

Serialization (save and loading)

Scheduled Pinned Locked Moved C#
graphicsdockerjsonhelp
5 Posts 2 Posters 0 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.
  • B Offline
    B Offline
    BLaZiNiX
    wrote on last edited by
    #1

    I created an application that Store an ArrayList (of file and file data) in a File using Serialization with BinaryFormater. What I want to do it's to load each filepath stored in the file I created with the Serialization and create the path. After the path is created I want to store the data of the equivalent file that is store in the file I created with the Serialization in the new file I created in the loading process. My problem is here : using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using System.Text; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; namespace MultipleFile { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private ArrayList r,w,data,read,n,m; private BinaryFormatter a,b,c; private StreamReader reader; private StreamWriter sr; private string path,content,npath; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); r = new ArrayList(); w = new ArrayList(); data = new ArrayList(); read = new ArrayList(); a = new BinaryFormatter(); b = new BinaryFormatter(); c = new BinaryFormatter(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.SuspendLayout(); // //

    A 1 Reply Last reply
    0
    • B BLaZiNiX

      I created an application that Store an ArrayList (of file and file data) in a File using Serialization with BinaryFormater. What I want to do it's to load each filepath stored in the file I created with the Serialization and create the path. After the path is created I want to store the data of the equivalent file that is store in the file I created with the Serialization in the new file I created in the loading process. My problem is here : using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO; using System.Text; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; namespace MultipleFile { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private ArrayList r,w,data,read,n,m; private BinaryFormatter a,b,c; private StreamReader reader; private StreamWriter sr; private string path,content,npath; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); r = new ArrayList(); w = new ArrayList(); data = new ArrayList(); read = new ArrayList(); a = new BinaryFormatter(); b = new BinaryFormatter(); c = new BinaryFormatter(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.SuspendLayout(); // //

      A Offline
      A Offline
      Andres Manggini
      wrote on last edited by
      #2

      I haven't run the code, but why don't you just do something like this ? Stream s = File.Open("D:\\path.dat",FileMode.Create,FileAccess.ReadWrite); a.Serialize(s,<>); b.Serialize(s,<>); Wouldn't that work ?. Andres Manggini. Buenos Aires - Argentina.

      B 1 Reply Last reply
      0
      • A Andres Manggini

        I haven't run the code, but why don't you just do something like this ? Stream s = File.Open("D:\\path.dat",FileMode.Create,FileAccess.ReadWrite); a.Serialize(s,<>); b.Serialize(s,<>); Wouldn't that work ?. Andres Manggini. Buenos Aires - Argentina.

        B Offline
        B Offline
        BLaZiNiX
        wrote on last edited by
        #3

        yes that's work, the first BinFormater (a) will store the path and the second (b) will store the data of each files I'm ok for the Storing(Save) but my problem is when I want to Deserialize the file to take the data from the (a) to create file and the data from the (b) to store it to the new file I create in (a). Do you understand what I want to do ? I know it's not clear but it's the way I want this thing works :) Thanks Jonathan Pouliot TeckSys Developer http://www.tecksys.com

        A 1 Reply Last reply
        0
        • B BLaZiNiX

          yes that's work, the first BinFormater (a) will store the path and the second (b) will store the data of each files I'm ok for the Storing(Save) but my problem is when I want to Deserialize the file to take the data from the (a) to create file and the data from the (b) to store it to the new file I create in (a). Do you understand what I want to do ? I know it's not clear but it's the way I want this thing works :) Thanks Jonathan Pouliot TeckSys Developer http://www.tecksys.com

          A Offline
          A Offline
          Andres Manggini
          wrote on last edited by
          #4

          Let me see if I understand correctly. You have two arrays, one contain a list of file names, the other a list of data corresponding to each file. So, you want to create as many files as the first array contains, and write the data contained in the second array to the corresponding file. is this correct ?. this sentence confuses me: /* copy */ I want to replace the button3_onclick event where the MEssageBox are with a File Creation and data transfer to the new file created... and I want to create it in ONE file (store the data and the file path in the same file not in two separate files) /* copy */ what do you mean by "(store the data and the file path in the same file not in two separate files)" ? Andres Manggini. Buenos Aires - Argentina.

          B 1 Reply Last reply
          0
          • A Andres Manggini

            Let me see if I understand correctly. You have two arrays, one contain a list of file names, the other a list of data corresponding to each file. So, you want to create as many files as the first array contains, and write the data contained in the second array to the corresponding file. is this correct ?. this sentence confuses me: /* copy */ I want to replace the button3_onclick event where the MEssageBox are with a File Creation and data transfer to the new file created... and I want to create it in ONE file (store the data and the file path in the same file not in two separate files) /* copy */ what do you mean by "(store the data and the file path in the same file not in two separate files)" ? Andres Manggini. Buenos Aires - Argentina.

            B Offline
            B Offline
            BLaZiNiX
            wrote on last edited by
            #5

            you almost got it : I want to create a file(just one file) in with I will store all the file path and each of these file DATA. this Part i'm ok. the part I don't know how : When I load the file i created with all the file path and file data in, I want to retake all the file path one by one and recreate the file corresponding to the file path with his DATA ( it's something like a copy process, but all the file path and data are store in one file and when I load the file I want to replace all the files at their place with their data) Is it more clearful now ? I hope, because I don't know very well how I can explain this. And I'm french so ... :) Jonathan Pouliot TeckSys Developer http://www.tecksys.com

            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