static void Main(string[] args) { ShowManager manager; string FileName = Directory.GetCurrentDirectory(); FileName += "\\ShowData.data"; if (File.Exists(FileName)) { Stream ReadStream = File.OpenRead(FileName); BinaryFormatter deserializer = new BinaryFormatter(); manager = (ShowManager)deserializer.Deserialize(ReadStream); //manager.playRandomEpisode("Futurama"); ReadStream.Close(); Stream WriteStream = File.OpenWrite(FileName); BinaryFormatter serializer = new BinaryFormatter(); serializer.Serialize(WriteStream, manager); WriteStream.Close(); } else { manager = new ShowManager("J:\\TV Shows"); manager.Populate(); //manager.playRandomEpisode("Futurama"); Stream s = File.Create(FileName); BinaryFormatter serializer = new BinaryFormatter(); serializer.Serialize(s, manager); s.Close(); } }
private void loadManager() { string FileName = Directory.GetCurrentDirectory(); FileName += "\\ShowData.data"; if (File.Exists(FileName)) { Stream ReadStream = File.OpenRead(FileName); BinaryFormatter deserializer = new BinaryFormatter(); this.manager = (ShowManager)deserializer.Deserialize(ReadStream); ReadStream.Close(); } else { this.manager = new ShowManager("J:\\TV Shows"); this.manager.Populate(); } }