public clsScanner LoadScanner() { //Cargar desde el app.config todos los datos clsScanner Scanner = new clsScanner(); try { Scanner.Description = ConfigurationManager.AppSettings["Scanner"]; Scanner.DPI = ConfigurationManager.AppSettings["DPI"]; Scanner.Depth = ConfigurationManager.AppSettings["Depth"]; Scanner.Size = ConfigurationManager.AppSettings["Size"]; Scanner.Duplex = Convert.ToBoolean(ConfigurationManager.AppSettings["Duplex"]); } catch { Scanner.Description = ""; } return(Scanner); }
public void SaveScanner(clsScanner Scanner) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); try { config.AppSettings.Settings["Scanner"].Value = Scanner.Description; config.AppSettings.Settings["DPI"].Value = Scanner.DPI; config.AppSettings.Settings["Depth"].Value = Scanner.Depth; config.AppSettings.Settings["Size"].Value = Scanner.Size; config.AppSettings.Settings["Duplex"].Value = Scanner.Duplex.ToString(); } catch { config.AppSettings.Settings.Add("Scanner", Scanner.Description); config.AppSettings.Settings.Add("DPI", Scanner.DPI); config.AppSettings.Settings.Add("Depth", Scanner.Depth); config.AppSettings.Settings.Add("Size", Scanner.Size); config.AppSettings.Settings.Add("Duplex", Scanner.Duplex.ToString()); } config.Save(ConfigurationSaveMode.Full); }