//SERAILIZATION // Create file to save the data to FileStream fs = new FileStream(@"C:\Date.Data", FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); // Use the BinaryFormatter object to serialize the data to the file bf.Serialize(fs, System.DateTime.Now); // Close the file fs.Close(); //DESERAILIZATION // Open file to read the data from fs = new FileStream(@"C:\Date.Data", FileMode.Open); DateTime data=new DateTime(); // Use the BinaryFormatter object to deserialize the data from the file data = (DateTime)bf.Deserialize(fs); // Close the file fs.Close(); // Display the deserialized string Console.WriteLine(data);