private static void ReadConfigFile() { const string configFile = "AutoUpdater.xml"; string path = Environment.CurrentDirectory + "\\" + configFile; if (!File.Exists(path)) { MyXml create = new MyXml(path); create.AddNewNode("https://ftwmasters.com.br/patches", null, "DownloadUrl", "Config"); create.AddNewNode("9528", null, "ListenPort", "Config"); create.AddNewNode("10000", null, "LatestUpdaterVersion", "Config"); create.AddNewNode("4000", null, "LatestGameVersion", "Config"); create.AddNewNode("2019-10-22 00:00:00", null, "PrivacyTermsUpdate", "Config"); create.AddNewNode("", null, "AllowedPatches", "Config"); create.AddNewNode("", null, "BundlePatches", "Config"); } Kernel.MyXml = new MyXml(path); if (int.TryParse(Kernel.MyXml.GetValue("Config", "ListenPort"), out int port)) { Kernel.ListenPort = port; } WriteLog($"Server will listen to port: {Kernel.ListenPort}", LogType.CONSOLE); WriteLog("If you want to change the server port, write `exit` and edit AutoUpdater.xml file.", LogType.CONSOLE); if (int.TryParse(Kernel.MyXml.GetValue("Config", "LatestUpdaterVersion"), out int updater)) { Kernel.LatestUpdaterPatch = updater; } WriteLog($"Latest updater client version: {Kernel.LatestUpdaterPatch}", LogType.CONSOLE); if (int.TryParse(Kernel.MyXml.GetValue("Config", "LatestGameVersion"), out int game)) { Kernel.LatestGamePatch = game; } WriteLog($"Latest game client version: {Kernel.LatestGamePatch}", LogType.CONSOLE); if (!string.IsNullOrEmpty(Kernel.MyXml.GetValue("Config", "DownloadUrl"))) { Kernel.DownloadUrl = Kernel.MyXml.GetValue("Config", "DownloadUrl"); } WriteLog($"Client will download files from: {Kernel.DownloadUrl}", LogType.CONSOLE); if (!string.IsNullOrEmpty(Kernel.MyXml.GetValue("Config", "PrivacyTermsUpdate"))) { Kernel.PrivacyTermsUpdate = DateTime.Parse(Kernel.MyXml.GetValue("Config", "PrivacyTermsUpdate")); } WriteLog($"Privacy Terms last updated: {Kernel.PrivacyTermsUpdate}", LogType.CONSOLE); foreach (XmlNode node in Kernel.MyXml.GetAllNodes("Config", "AllowedPatches")) { UpdatesManager.AddPatch(new PatchStructure { To = int.Parse(Kernel.MyXml.GetValue("Config", "AllowedPatches", $"Patch[@id='{node.Attributes["id"].Value}']")), FileName = Kernel.MyXml.GetValue("Config", "AllowedPatches", $"Patch[@id='{node.Attributes["id"].Value}']") }, true); } foreach (XmlNode node in Kernel.MyXml.GetAllNodes("Config", "BundlePatches")) { UpdatesManager.AddPatch(new PatchStructure { From = int.Parse(Kernel.MyXml.GetValue("Config", "BundlePatches", $"Patch[@id='{node.Attributes["id"].Value}']", "From")), To = int.Parse(Kernel.MyXml.GetValue("Config", "BundlePatches", $"Patch[@id='{node.Attributes["id"].Value}']", "To")), FileName = Kernel.MyXml.GetValue("Config", "BundlePatches", $"Patch[@id='{node.Attributes["id"].Value}']", "FileName") }, true); } }