Is there a C # analogue of the java.util.Properties class

Java has a class of properties that is good for storing basic configuration information, for example. the gui settings that you would like to transfer from one session to another. It saves and retrieves pairs of key values, as I recall, and is pretty easy to use. I was looking for an analogue of this in C #, but to no avail. Am I missing this?

If not, is there something above and above just saving / reading the custrom text file to save a simple application setup? (The measure "above and above" is simplicity).

+6
java c # file persistence
source share
4 answers

If you create a standard .NET project and go to "Properties", go to "Settings", then click "Create", you can complete what you want. This will allow you to use Properties.Settings, which is good for persistent user settings.

If you want to use the wide application settings, the app.config method (compiled as MyApplication.exe.config) is the way to go. You can access these settings using ConfigurationManager.AppSettings (link to the System.Configuration assembly required)

+6
source share

System.Configuration.ConfigurationManager is what you are looking for. It allows you to save / read key / value pairs in the app.config / web.config file for your application.

If you want to save user data, you can also check the settings file: Using settings in C #

+3
source share

Yes. Search

 Properties.Settings 
0
source share

There is an exact solution to what you want. please find the article here

his code has a bunch of strengths regarding performance.

  • The application does not load a text file in each request. It loads a text file only once into memory. For a subsequent query, it returns a value directly from memory. This is much more effective if your text file contains thousands or more key-value pairs.
  • Any change to the text file does not require a restart of the application. The file system watcher was used to track file status. If it changes, it fires an event and loads new changes according to memory, so that you can change the text file in one application / text editor and see the changed effect in the web application.
  • You can not only use it in a web application, but also use it in any desktop application.

Thanks. Have a nice day.

0
source share

All Articles