public static DicomSnapshotEntities TestLoad(string baseFolder) { BaseFolder = baseFolder; Filename = Path.Combine(BaseFolder, "DicomSnapshotEntities.xml"); if (!File.Exists(Filename)) { //MessageBox.Show("ûÓÐÊý¾Ý"); return(null); //TestSave(new AirwayPatients()); } var serializer = new DataContractSerializer(typeof(DicomSnapshotEntities)); DicomSnapshotEntities o = null; using (var stream = new MemoryStream(File.ReadAllBytes(Filename))) { o = serializer.ReadObject(stream) as DicomSnapshotEntities; } return(o); }
public static void TestSave(DicomSnapshotEntities patients, string baseFolder) { BaseFolder = baseFolder; Filename = Path.Combine(BaseFolder, "DicomSnapshotEntities.xml"); if (!Directory.Exists(BaseFolder)) { Directory.CreateDirectory(BaseFolder); if (!File.Exists(Filename)) { //File.Create(Filename); File.Copy("DicomSnapshotEntities.xml", Filename, true); //File.WriteAllText(Filename,"<ArrayOfAirwayPatient></ArrayOfAirwayPatient>"); } } var serializer = new DataContractSerializer(typeof(DicomSnapshotEntities)); using (var stream = new MemoryStream()) { serializer.WriteObject(stream, patients); File.WriteAllBytes(Filename, stream.ToArray()); } }