public Databases() { //Constructor //Load the database names, ip, port, usernames, passwords, and so on from file string line; string databasesFileLocation = null; //check the Arma2 root directory first if (File.Exists("Databases.txt")) { databasesFileLocation = Path.GetFullPath("Databases.txt"); } else { Logger.addMessage(Logger.LogType.Warning, "Unable to find the Databases.txt file here: " + Path.GetFullPath("Databases.txt")); databasesFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Arma2NETMySQL/Databases.txt"); if (!File.Exists(databasesFileLocation)) { Logger.addMessage(Logger.LogType.Error, "Unable to find the Databases.txt here: " + databasesFileLocation); } } Logger.addMessage(Logger.LogType.Info, "Databases.txt file loading in from: " + databasesFileLocation); StreamReader sr = File.OpenText(databasesFileLocation); line = sr.ReadLine(); while (line != null) { //Make sure it's not a comment if (!line.StartsWith("#")) { //Separate out the information string[] split = line.Split(','); if (split.Length == 6) { split[0] = split[0].ToLower(); Logger.addMessage(Logger.LogType.Info, "Type: " + split[0] + " Database: " + split[1] + " IPAddress: " + split[2] + " Port: " + split[3] + " Username: "******" Password: NotShownForSecurityReasons"); DatabaseObject temp = new DatabaseObject(new string[6] {split[0], split[1], split[2], split[3], split[4], split[5]}); databaseList.Add(temp); } else if (split.Length == 2) { split[0] = split[0].ToLower(); Logger.addMessage(Logger.LogType.Info, "Type: " + split[0] + " Database: " + split[1]); DatabaseObject temp = new DatabaseObject(new string[2] {split[0], split[1]}); databaseList.Add(temp); } else if (line.Contains(",")) { Logger.addMessage(Logger.LogType.Error, "Unable to parse line: " + line + " in Databases.txt file."); } } line = sr.ReadLine(); } sr.Close(); }
public Databases() { //Constructor //Load the database names, ip, port, usernames, passwords, and so on from file string line; string databasesFileLocation = null; //check the Arma2 root directory first if (File.Exists("Databases.txt")) { databasesFileLocation = Path.GetFullPath("Databases.txt"); } else { Logger.addMessage(Logger.LogType.Warning, "Unable to find the Databases.txt file here: " + Path.GetFullPath("Databases.txt")); databasesFileLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Arma2NETMySQL/Databases.txt"); if (!File.Exists(databasesFileLocation)) { Logger.addMessage(Logger.LogType.Error, "Unable to find the Databases.txt here: " + databasesFileLocation); } } Logger.addMessage(Logger.LogType.Info, "Databases.txt file loading in from: " + databasesFileLocation); StreamReader sr = File.OpenText(databasesFileLocation); line = sr.ReadLine(); while (line != null) { //Make sure it's not a comment if (!line.StartsWith("#")) { //Separate out the information string[] split = line.Split(','); if (split.Length == 6) { split[0] = split[0].ToLower(); Logger.addMessage(Logger.LogType.Info, "Type: " + split[0] + " Database: " + split[1] + " IPAddress: " + split[2] + " Port: " + split[3] + " Username: "******" Password: NotShownForSecurityReasons"); DatabaseObject temp = new DatabaseObject(new string[6] { split[0], split[1], split[2], split[3], split[4], split[5] }); databaseList.Add(temp); } else if (split.Length == 2) { split[0] = split[0].ToLower(); Logger.addMessage(Logger.LogType.Info, "Type: " + split[0] + " Database: " + split[1]); DatabaseObject temp = new DatabaseObject(new string[2] { split[0], split[1] }); databaseList.Add(temp); } else if (line.Contains(",")) { Logger.addMessage(Logger.LogType.Error, "Unable to parse line: " + line + " in Databases.txt file."); } } line = sr.ReadLine(); } sr.Close(); }