예제 #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();
        }