[dba-VB] Application settings

Gustav Brock Gustav at cactus.dk
Fri Dec 4 15:39:43 CST 2009

Hi Shamil

Yes, but is PropertyName appended and saved if it didn't exist?

Isn't the data saved under the user profile somewhere in AppData? I haven't look closer at this though.


>>> shamil at smsconsulting.spb.ru 04-12-2009 21:33 >>>
Hi Gustav,

You can set 

Properties.Settings.Default.{{PropertyName}} = {{SomeValue}};

and save settings having "User" scope:


And they are saved not in {{ApplicationExecutableFileName}}.config, which you deliver with you app's executable but anywhere else on your system -
probably somewhere in user's Application Settings - standard windows folder.
I have never had time to find out where settings are saved. Anybody?


- settings are loaded from {{ApplicationExecutableFileName}}.config when you deliver you application, and it runs first time;
- as soon as you save "User" scope settings they are saved in and loaded from {{UnknownPlace}};
- if you move your application files into another folder on the same system the settings are again loaded on first run from {{ApplicationExecutableFileName}};
- ...

That looks confusing a bit but it's how it works...

You can click "Learn more about application settings..." on top right of VS2008 application settings window available by Solution Explorer -> Project
name -> Right-Click -> Settings...

But if you wanted to have rather complicated structure of your application settings file then better use your own custom XML files, which can be loaded
from/saved to files many ways without almost any coding...

Thank you.


-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com 
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Friday, December 04, 2009 8:25 PM
To: dba-vb at databaseadvisors.com 
Subject: Re: [dba-VB] Application settings

Hi John

Shamil is right, but that method is for reading only.
Please note that the Properties' collection object is read-only, thus it
takes quite a few steps to add a property:


I have not used this as I haven't had any need to add properties on the fly.
Reading and writing was fine for me, and new properties I added manually.

You may find it much easier and perhaps more convenient to just have a
dataset which you read and write from/to an XML-file. I've posted code for
this before.


>>> jwcolby at colbyconsulting.com 04-12-2009 17:33 >>>
Under the project is a properties object.  Double click that and an entire multi-tabbed dialog opens.

Click the settings tab.  There you will see a form where you can enter name, type, scope, value.

As far as I can tell this is a place where I (the developer) can create settings that my program 
will use and manipulate, settings (for example) to tell my program the name of the SQL Server 
instance to use in a connection string, the name of my control database where I store my stored 
procedures and UDFs.  Stuff like that.  Stuff that I am currently hard coding, but which really 
should be in a settings tab so that I don't have to remember where that constant is in code, I can 
just go to the settings tab to change.

My expectation is that there is an object somewhere in the .net namespace that allows you to do 
something like "Something.Somethingelse.Settings["MyServerName"]...." to access these things.

I expect to be able to create new ones, edit existing ones, delete them etc from a .Net object.  I 
am looking for that .Net syntax that allows me to do this from code.

John W. Colby

More information about the dba-VB mailing list