public void Write(ToDoTask contents) { var writer = new System.Xml.Serialization.XmlSerializer(contents.GetType()); string filePath = HttpContext.Current.Server.MapPath("~/App_Data/toDoTasks.xml"); var wfile = new System.IO.StreamWriter(filePath); writer.Serialize(wfile, contents); wfile.Close(); }