Пример #1
0
        private void BinaryFormatterReader()
        {
            BinaryFormatter formater = new BinaryFormatter();
            FileStream      stream   = new FileStream("nikhil.bak", FileMode.Open);
            var             obj      = formater.Deserialize(stream);

            DemoClass demo = obj as DemoClass;

            txtContents.Text = demo.ToString();
            stream.Close();
            stream.Dispose();
        }
Пример #2
0
        private void XmlFormatterReader()
        {
            XmlSerializer formatter = new XmlSerializer(typeof(DemoClass));
            FileStream    stream    = new FileStream("nikhil.txt", FileMode.Open);
            var           obj       = formatter.Deserialize(stream);

            DemoClass demo = obj as DemoClass;

            txtContents.Text = demo.ToString();
            stream.Close();
            stream.Dispose();
        }
Пример #3
0
        private void XmlFormatterWriter()
        {
            XmlSerializer formatter = new XmlSerializer(typeof(DemoClass));
            FileStream    stream    = new FileStream("nikhil.txt", FileMode.Create);

            DemoClass demo = new DemoClass(2);

            demo.Id   = 2134;
            demo.Age  = 12;
            demo.Name = "Nikhil";

            formatter.Serialize(stream, demo);
            stream.Close();
            stream.Dispose();
        }
Пример #4
0
        private static void BinaryFormatterWriter()
        {
            BinaryFormatter formater = new BinaryFormatter();

            FileStream stream = new FileStream("nikhil.bak", FileMode.Create);

            DemoClass demo = new DemoClass(2);

            demo.Id   = 2134;
            demo.Age  = 12;
            demo.Name = "Nikhil";

            formater.Serialize(stream, demo);
            stream.Close();
            stream.Dispose();
        }