public static EathenaConfigFileCollection Load(string Name) { EathenaConfigFileCollection files = new EathenaConfigFileCollection(); EathenaConfigFile config = new EathenaConfigFile(); if (Directory.Exists(Name) == false) { if (ConfParser.ReadFile(Name, out config) == true) { files.Add(Name.GetPathParts("conf"), config); } return(files); } string[] Files = Directory.GetFiles(Name, "*.conf"); for (int i = 0; i < Files.Length; i++) { if (ConfParser.ReadFile(Files[i], out config) == true) { files.Add(Files[i].GetPathParts("conf"), config); } } string[] Dirs = Directory.GetDirectories(Name); for (int i = 0; i < Dirs.Length; i++) { files.AddRange(ConfParser.Load(Dirs[i])); } return(files); }
private bool LoadSettings() { string path = Properties.Settings.Default.ConfigDirectory; mBaseColorScheme = Properties.Settings.Default.GUITheme; chkSettingSaveOnExit.Checked = Properties.Settings.Default.SaveOnExit; chkSettingComments.Checked = Properties.Settings.Default.ShowComments; chkSettingBackup.Checked = Properties.Settings.Default.CreateBackup; do { // is <path> valid? if (path.IsNullOrEmpty() || System.IO.Directory.Exists(path) == false) { FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.Description = "Bitte wähle deinen eAthena Config Ordner aus!\nz.B.: C:/eAthena/conf/"; if (dlg.ShowDialog() != DialogResult.OK) { path = string.Empty; // let the rest know what he did... break; } string[] pathParts = dlg.SelectedPath.Split(new char[] { '\\' }); if (pathParts.Length == 0 || pathParts[pathParts.Length - 1].ToLower() != "conf") { path = string.Empty; Tools.Error("Fehler im Pfad", "Dein angegebener Pfad is ungültig!\nDu musst einen eAthena Config Ordner auswählen!\n\nz.B.: C:/eAthena/conf/"); continue; } // he selected a Dir! path = dlg.SelectedPath; } // searching for Files in the dir if (path != string.Empty) { mFiles = ConfParser.Load(path); } if (mFiles != null && mFiles.Count > 0) // found some, break out! { break; } // nothing found, continue? if (MessageBoxEx.Show("Es wurden keine Config Datein in dem Ordner gefunden!\nBitte wähle den richtigen Ordner aus!\n\nBeispiel: C:/eAthena/conf/\n\n\nMöchtest du es nochmal versuchen?", "Config Fehler", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Cancel) { break; } // reset if we continue so the first check show us the Dialog again path = string.Empty; } while(true); if (mFiles.Count == 0) // breaked out, no continue :/ { return(false); } // all valid, save the dir if (path != Properties.Settings.Default.ConfigDirectory) { Properties.Settings.Default.ConfigDirectory = path; } return(true); }