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