private void Save() { try { XmlSerializer serializer = new XmlSerializer(typeof(ModelClasses.Items)); TextWriter writer = new StreamWriter(itemsFile); if (allItems != null && allItems.Any()) { serializer.Serialize(writer, allItems); } writer.Close(); } catch (Exception e) { MessageBox.Show("Oh Oh, ich kann nicht speichern: " + e.Message); } }
//itemsFile public void SaveItems(string targetFile) { try { XmlSerializer serializer = new XmlSerializer(typeof(ModelClasses.Items)); TextWriter writer = new StreamWriter(targetFile); if (existingItems != null && existingItems.Any()) { serializer.Serialize(writer, existingItems); } writer.Close(); } catch (Exception e) { MessageBox.Show("Oh Oh, ich kann nicht speichern: " + e.Message); } }