private void UpdateIniConfig() { IniFile file = new IniFile(options); file.Load(Path); ConfigWeb config = JsonConvert.DeserializeObject <ConfigWeb>(webConfig); file.Sections["database"].Keys["Host"].Value = config.dbHost; file.Sections["database"].Keys["User"].Value = config.dbUser; file.Sections["database"].Keys["Pass"].Value = config.dbPass; file.Sections["database"].Keys["Database"].Value = config.dbDatabase; file.Save(Path); }
//Salva as Configurações no arquivo Ini private void SaveIniConfig() { IniFile file = new IniFile(options); file.Load(Path); IniSection section = file.Sections.Add("database"); ConfigWeb config = JsonConvert.DeserializeObject <ConfigWeb>(webConfig); IniKey key = section.Keys.Add("Host", config.dbHost); key = section.Keys.Add("User", config.dbUser); key = section.Keys.Add("Pass", config.dbPass); key = section.Keys.Add("Database", config.dbDatabase); file.Save(Path); }
public static ConfigWeb GetConfig() { IniOptions options = new IniOptions() { Compression = true, EncryptionPassword = "******" }; ConfigWeb config = new ConfigWeb(); IniFile file = new IniFile(options); file.Load(Path); config.dbHost = file.Sections["database"].Keys["Host"].Value; config.dbUser = file.Sections["database"].Keys["User"].Value; config.dbPass = file.Sections["database"].Keys["Pass"].Value; config.dbDatabase = file.Sections["database"].Keys["Database"].Value; return(config); }