Where to store configuration for a simple .NET application?

后端 未结 7 2052
死守一世寂寞
死守一世寂寞 2020-12-16 00:50

I\'m programming a fairly simple application which I want to cut to just one simple EXE file + some data storage (XML for example).

My question is regarding configur

相关标签:
7条回答
  • 2020-12-16 01:30

    Please see: WPF/C#: Where should I be saving user preferences files?

    0 讨论(0)
  • 2020-12-16 01:33

    I would store them in the same directory. That just seems easier to me, at least that's the way I always do it.

    0 讨论(0)
  • 2020-12-16 01:34

    Do not forget Isolated Storage. It gives you a place to read and write files to without the need for you to specify a location. Sometimes it is the only way sandboxed applications (like Silverlight) can store user or machine specific data locally. See here for an example.

    0 讨论(0)
  • 2020-12-16 01:37

    EXE-only programs store their data either in the Windows Registry or in the user's Application Data/AppData folder. Although this may appear cleaner at first, it just hides the ugliness of scattering all your data around. I would suggest just going with a simple XML/INI/text data file that is generated when needed and easy to migrate.

    0 讨论(0)
  • 2020-12-16 01:37

    You could use the app.config file for storing your configuration. For the data, I would sugest something like db4o or SQLite.

    Edit

    This tutorial can show you how simple is to use db40 to store and retrieve your data.

    0 讨论(0)
  • 2020-12-16 01:46

    I think you want to take a look at Application Settings. This is an API which allows you to save user or application settings using a strongly typed API. Under the hood the settings are stored via XML serialization.

    This API works with virtually every type of .Net application including low permission Click Once versions. It does the work of finding the place on disk appropriate for storing the data and completely hides it from you. It also has a nice GUI integration into Visual Studio.

    0 讨论(0)
提交回复
热议问题