Wrapper class for programatically creating application settings

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JnrJnr
    New Member
    • Oct 2009
    • 88

    #1

    Wrapper class for programatically creating application settings

    I am creating a wrapper class that derives from the ApplicationSett ingsBase class to programmaticall y 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.

    Code:
    public class myUserSetting : ApplicationSettingsBase 
            {
                [UserScopedSetting()]
                //[DefaultSettingValue("")]
                public String newDir
                {
                    get
                    {
                        return ((String)this["newDir"]);
                    }
                    set
                    {
                        this["newDir"] = (String)value;
                    }
                }
            }
            myUserSetting mySetting;
            private void Form1_Load(object sender, EventArgs e)
            {
                mySetting = new myUserSetting();
                            MessageBox.Show("derectory = " + mySetting.newDir + "       Properties Count = " + mySetting.Properties.Count.ToString());
            }
    
    private void button1_Click(object sender, EventArgs e)
            {
                mySetting.newDir = //random directory I have selected
                mySetting.Save();
                MessageBox.Show("Directry = " + mySetting .newDir);
            }
    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 programmaticall y? Is this code right, am I on the right track?
    The reason I want to do this programmaticall y is because I want the user to assign a Name(setting) and Value(C:\blah\b lah\bah) to create new settings and save them in my application.
    any help would be much appreciated
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    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>\applicati on 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?

    Comment

    • JnrJnr
      New Member
      • Oct 2009
      • 88

      #3
      I found the location of the user.config files, it is in
      C:\Users\name\A ppData\Local\Mi crosoft\Project _name.exe_some_ URL
      I have used a different approach to saving my settings. Im not using the rapper class anymore
      Thanx

      Comment

      Working...