By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,742 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,742 IT Pros & Developers. It's quick & easy.

Wrapper class for programatically creating application settings

JnrJnr
P: 88
I am creating a wrapper class that derives from the ApplicationSettingsBase class to programmatically create application settings for a windows form.
I got it right to save my setting but now I want to know where is this "file" or ".config file" stored so I can view all the settings I have created.

Expand|Select|Wrap|Line Numbers
  1. public class myUserSetting : ApplicationSettingsBase 
  2.         {
  3.             [UserScopedSetting()]
  4.             //[DefaultSettingValue("")]
  5.             public String newDir
  6.             {
  7.                 get
  8.                 {
  9.                     return ((String)this["newDir"]);
  10.                 }
  11.                 set
  12.                 {
  13.                     this["newDir"] = (String)value;
  14.                 }
  15.             }
  16.         }
  17.         myUserSetting mySetting;
  18.         private void Form1_Load(object sender, EventArgs e)
  19.         {
  20.             mySetting = new myUserSetting();
  21.                         MessageBox.Show("derectory = " + mySetting.newDir + "       Properties Count = " + mySetting.Properties.Count.ToString());
  22.         }
  23.  
  24. private void button1_Click(object sender, EventArgs e)
  25.         {
  26.             mySetting.newDir = //random directory I have selected
  27.             mySetting.Save();
  28.             MessageBox.Show("Directry = " + mySetting .newDir);
  29.         }
I know that when you create application settings through the designer you can actually go to the designer and change values, scope, and type etc. You can also see and change application settings values by clicking on app.config file in solution explorer. But where is it stored when done programmatically? Is this code right, am I on the right track?
The reason I want to do this programmatically is because I want the user to assign a Name(setting) and Value(C:\blah\blah\bah) to create new settings and save them in my application.
any help would be much appreciated
Dec 7 '10 #1
Share this Question
Share on Google+
2 Replies


GaryTexmo
Expert 100+
P: 1,501
I think the file goes in your user folder, which depends on the operating system for its location. Like, in XP it's something like:

c:\documents and settings\<user name>\application data (or maybe local settings)

For Vista and up, I think they change the structure a bit and put it in a c:\Users folder.

I think anyway, check it out?
Dec 8 '10 #2

JnrJnr
P: 88
I found the location of the user.config files, it is in
C:\Users\name\AppData\Local\Microsoft\Project_name .exe_some_URL
I have used a different approach to saving my settings. Im not using the rapper class anymore
Thanx
Dec 27 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.