public string readConfig(configVar config) { string text = File.ReadAllText(_filePath, Encoding.UTF8); Match match = Regex.Match(text, "(?m)^" + config.ToString() + "(.+)$", RegexOptions.IgnoreCase); if (match.Success) { string result = match.Groups[1].Value.ToString(); //(?m) = multiline if (result.IndexOf("").Equals(0)) { result = result.Remove(0, 1); } result = result.Replace("=", ""); //remove = return result.Trim(); } return null; }
public string readConfig(configVar config) { string text = File.ReadAllText(_filePath, Encoding.UTF8); Match match = Regex.Match(text, "(?m)^" + config.ToString() + "(.+)$", RegexOptions.IgnoreCase); if (match.Success) { string result = match.Groups[1].Value.ToString(); //(?m) = multiline if (result.IndexOf("").Equals(0)) { result = result.Remove(0, 1); } result = result.Replace("=", ""); //remove = return(result.Trim()); } return(null); }
public void writeConfig(configVar config, string value) { File.WriteAllText(_filePath, Regex.Replace(File.ReadAllText(_filePath), "(?m)^" + config.ToString() + "(=| .+|/ )$", config.ToString() + " = " + value)); }