.Settings files

I am trying to use a .settings file to store users application data such as database usernames and passwords etc.

I have set up a .settings file with a few entries such as:

Name: odbcName
Type: String
Scope:Application
Value:

I have been able to get the contents of the settings file if i put something in the value field by using the following code:

Settings1 mySettings = new Settings1();
String odbcName = mySettings.get_odbcName();

How, though do i modify the contents of the value field, and save it so that the next time the program is run, it contains the users new data

Regards

Richard



Answer this question

.Settings files

  • DanielKQ

    Hi,

    If you want to change the setting value at run time then it is not supported. Application-scoped settings are read-only and are shared between all users of that application. PLease refer "The New and Better Way" section of http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnvs05/html/vbmysettings.asp for more.

    If you want to change the value at compile time then just open the settings file in VS 2005. File will be opened in Settings designer and you can easily change the value there. If you are not using VS 2005 then just open the file in notepad or any xml editor and change the value of <value> node.

    <Setting Name="Setting" Type="System.String" Scope="User">
    <Value Profile="(Default)">Change it</Value>
    </Setting>

    Thanks.



  • prashantguptak

    Hi,

    Yes, you can change only user scope settings at runtime, not application level. This feature is a language agnostic one and is common to all languages so the link i have given above should be able to guide you. You just need to take care of VJ# syntax.

    And if you are using Visual Studio 2005 then it automatically generate .jsl file which will have code to get/set the values.

    Thanks.



  • GMSherif

    So are you saying that if i were to use "user" as the scope instead of application i would be able to read and write them Is there a VJ# guide on how to do this

    Regards
    Richard


  • .Settings files