// Guarda un item en un XML public static bool SaveAs(string filename, InventoryAdjustment inventoryAdjustment) { bool tResult = false; try { System.IO.File.WriteAllText(filename, inventoryAdjustment.ToString(), Encoding.Unicode); tResult = true; } catch { tResult = false; } return(tResult); }
// Carga un item desde un XML public static InventoryAdjustment LoadFrom(string filename) { InventoryAdjustment tInventoryAdjustment = null; try { var serializer = new XmlSerializer(typeof(InventoryAdjustment)); FileStream fs = new FileStream(filename, FileMode.Open); StreamReader stream = new StreamReader(fs, Encoding.Unicode); tInventoryAdjustment = (InventoryAdjustment)serializer.Deserialize(stream); fs.Close(); } catch { } return(tInventoryAdjustment); }