private void testSaveList() { ShutdownMembers test = new ShutdownMembers(); List <Member> MemberList = new List <Member>(); Member mem1 = new Member(); mem1.IP = "1.2.3.4"; mem1.Name = "DRStestSQL"; MemberList.Add(mem1); Member mem2 = new Member(); mem2.IP = "8.8.8.8"; mem2.Name = "google"; MemberList.Add(mem2); test.MemberList = MemberList; //TestSerializeToFile(test, "Hej"); XmlSerializer xsSubmit = new XmlSerializer(typeof(ShutdownMembers)); var subReq = test; var xml = ""; using (var sww = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sww)) { xsSubmit.Serialize(writer, subReq); xml = sww.ToString(); // Your XML } } }
public ShutdownMembers GetMemberList() { ShutdownMembers mem = null; string path = @"C:\SMS_temp\members.xml"; XmlSerializer serializer = new XmlSerializer(typeof(ShutdownMembers)); StreamReader reader = new StreamReader(path); mem = (ShutdownMembers)serializer.Deserialize(reader); reader.Close(); return(mem); }
public void ShutdownAll() { //testSaveList(); ShutdownMembers mem = null; string path = @"C:\SMS_temp\members.xml"; XmlSerializer serializer = new XmlSerializer(typeof(ShutdownMembers)); StreamReader reader = new StreamReader(path); mem = (ShutdownMembers)serializer.Deserialize(reader); reader.Close(); foreach (var member in mem.MemberList) { ShutdownPC(member.Name); //Console.WriteLine("Shutdown " + member.Name); } }