473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

get and set values of variables in settings file

134 100+
Is here someone which can give me an example of a code which I can use to set and get values of variables in my settings file?
Jul 31 '11 #1

✓ answered by Subin Ninan

  • In project properties > Settings
  • create a property with Name as USER and Type as String.

To set and get this property use below code:

Expand|Select|Wrap|Line Numbers
  1. //Store value in USER property from txtUser TextBox
  2.  
  3. Properties.Settings.Default.USER = txtUser.Text;
  4. Properties.Settings.Default.Save();
  5.  
  6.  
  7. //Read USER property in a variable username
  8.  
  9. string username = Properties.Settings.Default.USER;
  10.  

2 4245
  • In project properties > Settings
  • create a property with Name as USER and Type as String.

To set and get this property use below code:

Expand|Select|Wrap|Line Numbers
  1. //Store value in USER property from txtUser TextBox
  2.  
  3. Properties.Settings.Default.USER = txtUser.Text;
  4. Properties.Settings.Default.Save();
  5.  
  6.  
  7. //Read USER property in a variable username
  8.  
  9. string username = Properties.Settings.Default.USER;
  10.  
Aug 1 '11 #2
michaeldebruin
134 100+
Thanks a lot Subin Ninan
Aug 1 '11 #3

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

Similar topics

1
by: Ronnie Laurikkala | last post by:
In e.g. a Bourne shell script I can source variables and values; #!/bin/sh .. ${HOME}/script_common_lib How can I source variables and values from a file and use them in Perl-scripts? ...
2
by: John J. Hughes II | last post by:
Ok now I guess I am supposed to save my user setting in the new setting file. Which is placed in the users application directory under the company name based on version number. I really truly...
2
by: Ben Dewey | last post by:
Hey, I have kind of an architecture question. I have a dynamic website that is using a Windows Form Backend and a ASP.NET front end. They are both using C# 2.0. I also have a class library...
4
by: Jamie McQuay | last post by:
Does any one know if it is possible to set the location of a settings file? I want to use separate settings files for each user and will need to change the location. Thanks, Jamie
6
by: John J. Hughes II | last post by:
I am creating a new windows service and will have a windows form for setting the runtime settings. In the past I have used the registry for this but since MS seems to think this is a bad thing I...
1
by: =?Utf-8?B?YWtpcw==?= | last post by:
Hello, I have already spent a whole day on that so some help would be greatly appreciated. I have a windows service that in the settings file (created by the designer) has a bool debug=false the...
2
by: ssg31415926 | last post by:
I've got a small web site and I've added some settings in appSettings which appear in web.config. So far, so good. I've just added a DLL to the site which was originally written to be called...
2
by: sklett | last post by:
I'm having some trouble storing a string in my settings file that contains escape characters. If I enter "This is the first line\r\nand this is the second line." When I retrieve the string from...
1
by: sukumaster | last post by:
Hi How to change settings in a settings file using c#.NET.? Is tere any built in functions?
0
by: =?Utf-8?B?RnV0cm9uaWNzIERldmVsb3Blcg==?= | last post by:
I am trying to store a collection of custom types in a Properties.Settings file which I will be updating at run time and saving on exit of the program. I understand how to use the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.