private void SaveToFile(RatingLists ratingLists, string fileName) { string path = "files\\RatingCache\\" + fileName; FileStream outFile = File.Create(path); XmlSerializer formatter = new XmlSerializer(ratingLists.GetType()); formatter.Serialize(outFile, ratingLists); outFile.Close(); }
private RatingLists LoadFromFile(string filePath) { RatingLists ratingLists = new RatingLists(); XmlSerializer formatter = new XmlSerializer(ratingLists.GetType()); FileStream aFile = new FileStream(filePath, FileMode.Open); byte[] buffer = new byte[aFile.Length]; aFile.Read(buffer, 0, (int)aFile.Length); MemoryStream stream = new MemoryStream(buffer); return((RatingLists)formatter.Deserialize(stream)); }