Usually, when you have the application configuration file in the application, and your application should read it.
Is it good to check at startup if this file exists and cause an error, and not continue? (Worst cases of senarios)
Or leave it to an unhandled exception manager to process it and close the application? (WPF / Winforms etc.)
Consult?
A better approach would be to configure the correct default settings and work in the absence of a file. Indeed, what happens if the file is present, but some critical parameter has been deleted by the user?
, , , .
- , , triing, app.config:
private static int SomeValue { get { int result = 60; //Some default value string str = ConfigurationManager.AppSettings["SomeValue"]; if (!String.IsNullOrEmpty(str)) { Int32.TryParse(str, out result); } return result; } }
Source: https://habr.com/ru/post/1738924/More articles:Blackberry - port estimation Android applications with GPS and Google Maps - androidSpark viewer - why is there no VS integration in version 1.1? - asp.net-mvcJava call plugin class - javaHow to verify that "puts" was called with a specific message? - ruby | fooobar.comHow to write a class that can be accessed without naming it - c #Are column families within the same key space in any way? - cassandraHow to use facebook connection with cakephp? - facebookHow to improve Python regex syntax? - pythonAndroid - displays information about specific contacts - androidVisual Studio - плагин находит/удаляет мертвый код? - pluginsAll Articles