Пример #1
0
        private void serverForm2_FormClosing(object sender, FormClosingEventArgs e)
        {
            StoreShape sh = new StoreShape();

            sh.mypencil = mypencil;
            sh.mylines  = mylines;
            sh.mycircle = mycircle;
            sh.myrect   = myrect;
            sh.npencil  = npencil;
            sh.nline    = nline;
            sh.ncircle  = ncircle;
            sh.nrect    = nrect;
            sh.index    = index;

            Stream          stm = File.Open(filePath, FileMode.Create, FileAccess.Write);
            BinaryFormatter bf  = new BinaryFormatter();

            bf.Serialize(stm, sh);
            stm.Close();
        }
Пример #2
0
        private void serverForm2_Load(object sender, EventArgs e)
        {
            if (File.Exists(filePath))
            {
                // file exist
                Stream          stm = File.Open(filePath, FileMode.Open, FileAccess.Read);
                BinaryFormatter bf  = new BinaryFormatter();

                StoreShape sh = (StoreShape)bf.Deserialize(stm);
                stm.Close();

                mypencil = sh.mypencil;
                mylines  = sh.mylines;
                mycircle = sh.mycircle;
                myrect   = sh.myrect;
                npencil  = sh.npencil;
                nline    = sh.nline;
                ncircle  = sh.ncircle;
                nrect    = sh.nrect;
                index    = sh.index;
            }
        }