public void Write() { try { XmlSerializer serializer; FileInfo destFile; switch (Config) { case UOSReader.ConfigType.Profile: XML.Profile.Profile profile = CfgFile as XML.Profile.Profile; serializer = new XmlSerializer(typeof(XML.Profile.Profile)); destFile = Program.profiles[ProfileID]; if (File.Exists(destFile.FullName + ".backup")) { File.Delete(destFile.FullName + ".backup"); } destFile.CopyTo(destFile.FullName + ".backup"); using (FileStream fstream = destFile.OpenWrite()) { serializer.Serialize(fstream, profile); } break; case UOSReader.ConfigType.Launcher: XML.Launcher.Launcher launcher = CfgFile as XML.Launcher.Launcher; serializer = new XmlSerializer(typeof(XML.Launcher.Launcher)); destFile = new FileInfo(new DirectoryInfo(Program.Config.UOSPath).Parent.FullName + @"\launcher.xml"); if (File.Exists(destFile.FullName + ".backup")) { File.Delete(destFile.FullName + ".backup"); } destFile.CopyTo(destFile.FullName + ".backup"); using (FileStream fstream = destFile.OpenWrite()) { serializer.Serialize(fstream, launcher); fstream.Flush(); } break; } } catch (Exception ex) { Program.CMSG(ex); } }
public void LoadProfile(int ProfileID) { currentProfile = loadProfile(ProfileID); }