views:

207

answers:

7

Hello,

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 configuration files. Where to put those files? I saw few applications that have just exe file (uTorrent, Media Player Classic - I can use them without any installation), but they store their config somewhere else. How to achieve this?

How would you approach such situation? Is it better to try to achieve thing I described above, or simply use config file and data storage in the same directory as exe file?

+3  A: 

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

Mitch Wheat
+7  A: 

Creating or using a file in the same folder (or in the App_Data) is pretty standard practice.

You use an installer like Inno Setup (free) to create a single exe installer (http://www.jrsoftware.org/isinfo.php)

If you want a DB rather than XML, have a look at SQLite (http://www.sqlite.org/) a file based DB or use an MS Access DB.

Mark Redman
+3  A: 

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.

Fernando
+4  A: 

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.

Max Shawabkeh
A: 

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

This could give problems when the application tries to write to that file, since normal users don't have write permissions in the program files directory.
Lars Truijens
+1  A: 

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.

Lars Truijens
+1  A: 

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.

JaredPar