configuration-files

How to use .NET configuration files (app.config, settings.settings) to save and restore all application data?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 00:03:12
Although there are a lot of posts about .net config files, I believe that my requirements do not allow for any of the solutions proposed (or I don't understand the process enough to make it work for me). The situation is that I have a Windows Forms application (could just as well be another app) which binds certain user input fields (e.g. IP Address), as well as form properties (window size, etc) to application settings (in the Properties->Settings area). From what I understand, these settings are the same as those represented in my project's app.config file, so I should be able to use the

Reload configuration settings from an external config file during run-time

左心房为你撑大大i 提交于 2019-11-28 23:27:40
I'm writing a game server in C# and would like to reload or refresh settings from a config file while the server is running. Ideally I would like to save the settings in an XML file, have the ability to edit the file while the game server is running and then send the server the command to reload the settings from the file. I know I can use a database to do this as well, but the game server is fairly small and I think it would be more practical to just save settings in a flat-file. I will have file-level access to the machine the server will run on. What should I use? rene Use http://msdn

Get the App.Config of another Exe

两盒软妹~` 提交于 2019-11-28 23:02:04
I have an exe with an App.Config file. Now I want to create a wrapper dll around the exe in order to consume some of the functionalities. The question is how can I access the app.config property in the exe from the wrapper dll? Maybe I should be a little bit more in my questions, I have the following app.config content with the exe: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="myKey" value="myValue"/> </appSettings> </configuration> The question is how to how to get "myValue" out from the wrapper dll? thanks for your solution. Actually my initial concept was

Can ConfigurationManager retain XML comments on Save()?

纵然是瞬间 提交于 2019-11-28 21:11:42
I've written a small utility that allows me to change a simple AppSetting for another application's App.config file, and then save the changes: //save a backup copy first. var cfg = ConfigurationManager.OpenExeConfiguration(pathToExeFile); cfg.SaveAs(cfg.FilePath + "." + DateTime.Now.ToFileTime() + ".bak"); //reopen the original config again and update it. cfg = ConfigurationManager.OpenExeConfiguration(pathToExeFile); var setting = cfg.AppSettings.Settings[keyName]; setting.Value = newValue; //save the changed configuration. cfg.Save(ConfigurationSaveMode.Full); This works well, except for

Ruby loading config (yaml) file in same dir as source

我只是一个虾纸丫 提交于 2019-11-28 19:40:41
问题 in HOME/path_test/ I have: load_test.rb: require 'yaml' cnf = YAML::load(File.open('config.yml')) puts cnf['Hello'] config.yml: Hello: world!!! when in HOME/path_test/ I get as expected: -bash-3.2$ ruby load_test.rb world!!! when in HOME/ (cd ..) I get -bash-3.2$ ruby path_test/load_test.rb path_test/load_test.rb:3:in `initialize': No such file or directory - config.yml (Errno::ENOENT) from path_test/load_test.rb:3:in `open' from path_test/load_test.rb:3:in `<main>' Which is correct behavior,

WiX overwrites config files during setup. How can I avoid this?

孤者浪人 提交于 2019-11-28 19:23:37
I'm using WiX to create a windows installer. Unfortunately my installer overwrites a config file on every update. What I really want is, that the installer only creates the file if it is not found. Thanks and regards, forki I sure someone will come up with a proper answer, but as a backup: You could have the installer create a default configuration file, and then have your application copy the default file to the normal configuration file, if the normal configuration file is not present. This also provides an easy way to reset the application to factory default (just delete the configuration

How can I make a .NET class library read its own configuration file?

若如初见. 提交于 2019-11-28 18:50:24
I have a .NET class library that provides a set of helper functions that are used by several Web Services. This class library must store a single setting, specifically, a connection string, which need not be seen by the Web Services themselves, since they all must query the same datbase. Unfortunately, .NET provides no means to easily read a DLL's app.config file. The only "easy" solution would be to store the connection string in every single Web Service configuration file, which is completely bollocks. Normally, I care about code elegance, but this time I really need a solution, even if it

Could string comparisons really differ based on culture when the string is guaranteed not to change?

心已入冬 提交于 2019-11-28 18:32:14
I'm reading encrypted credentials/connection strings from a config file. Resharper tells me, "String.IndexOf(string) is culture-specific here" on this line: if (line.Contains("host=")) { _host = line.Substring(line.IndexOf( "host=") + "host=".Length, line.Length - "host=".Length); ...and so wants to change it to: if (line.Contains("host=")) { _host = line.Substring(line.IndexOf("host=", System.StringComparison.Ordinal) + "host=".Length, line.Length - "host=".Length); The value I'm reading will always be "host=" regardless of where the app may be deployed. Is it really sensible to add this

PHP - Application config file stored as - ini,php,sql,cached,php class,JSON,php array?

て烟熏妆下的殇ゞ 提交于 2019-11-28 18:19:01
I am trying to decide on the best way to store my applications configuration settings. There are so many options. The majority of applications I have seen have used a simple require and a PHP file that contains variables. There seem to be far more advanced techniques out there. What have you used? What is most efficient? What is most secure? The best thing you can do is the simplest thing that could possibly work (php variables) and wrap it up in a class. That way you can change the implementation later without changing any client code. Create an interface that the configuration class

How to read a configuration file in Java

烂漫一生 提交于 2019-11-28 18:11:35
I am doing a project to build thread pooled web server , in which I have to set the port number on which server listens. How many threads are there in thread pool Absolute Path of the root directory, and so many points. One way is to hard code all these variables in the code, that I did. But professionally it is not good. Now, I want to make one configuration file, in which I put all these data, and at the run time my code fetches these. How can I make configuration file for the above task ? Create a configuration file and put your entries there. SERVER_PORT=10000 THREAD_POOL_COUNT=3 ROOT_DIR=