Is there any class in C # for manipulating properties files?

4

In C # you have some class for handling files properties ? In java I use the class Properties , wanted to know if it has an equivalent in C #?

    
asked by anonymous 08.10.2016 / 20:45

3 answers

3

There are some libraries that allow you to do something very sophisticated. I would not know a specific one.

There is something a little different about the default library, the class ConfigurationManager .

You have a answer in SO with an example trying to reproduce the base of this class in C #.

    
08.10.2016 / 21:16
2

I am a layman in Java, but I believe he is talking about saving configuration information and / or miscellaneous information in one place to be "consumed" when necessary.

In C # there are some ways to do this, but the most correct is:

Web Applications: File Web.config

  

web.config is a special file, similar to the .htaccess used by Apache, which configures the behavior of your application. Created in XML format, it can be edited easily with a common editor such as Notepad.

     

Web.config is generally used to store values and parameters that are common to every application.

     

However, each Web application created can have its own web.config file, and the information in this file is valid for the current directory and its subdirectories.

     

source

There is a "section" within Web.config called appSettings which is used to "save" information that can be accessed later.

Ex:

  <appSettings>
    <add key="NomeSistema" value="Meu sistema" />
    <add key="UrlLocalhost" value="http://localhost" />
    <add key="UrlSite" value="http://meusite.com.br" />
    <add key="defaultCulture" value="pt-BR" />
  </appSettings>

If necessary, add the assembly reference:

using System.Configuration;

To access the data:

label.Text = ConfigurationManager.AppSettings["NomeSistema"];

Desktop Applications: File App.config

Same thing as in web application:

Ex:

  <appSettings>
    <add key="NomeSistema" value="Meu sistema" />
    <add key="UrlLocalhost" value="http://localhost" />
    <add key="UrlSite" value="http://meusite.com.br" />
    <add key="defaultCulture" value="pt-BR" />
  </appSettings>

If necessary, add the assembly reference:

using System.Configuration;

To access the data:

return ConfigurationManager.AppSettings["NomeSistema"];
    
08.10.2016 / 23:18
0

After many pains, I found this article in VOL ... talking about LibConfuse: link

I'm studying because I have a very similar problem and so far it has passed my tests ... not to mention that it's very easy to use.

BUT as I just did not test I'm not sure if it has a C # version.

    
10.10.2016 / 08:35