473,387 Members | 1,579 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.

how to read/write settings (using .ini, xml, whatever)?

I want to read/write user settings. I thought about using .ini
or .xml files. Are there classes in c# to handle this? The stuff I
find on the 'net seems old.

Titan

May 30 '07 #1
11 2954
On May 30, 8:49 am, titan nyquist <titan.nyqu...@gmail.comwrote:
I want to read/write user settings. I thought about using .ini
or .xml files. Are there classes in c# to handle this? The stuff I
find on the 'net seems old.
If you're using vs 2005, you can open the Project properties, click on
the Settings tab. You should get a link offering to create settings.
Put application and user settings in there. YOu can then use them via
Properties.Resources.Default.

HTH
Andy

May 30 '07 #2
With that, can create a GUI to let the user change these settings?
How are the saved from one session to the next (from one run of the
program to the next time)?

May 30 '07 #3
On May 30, 3:53 pm, Andy <a...@med-associates.comwrote:
On May 30, 8:49 am, titan nyquist <titan.nyqu...@gmail.comwrote:
I want to read/write user settings. I thought about using .ini
or .xml files. Are there classes in c# to handle this? The stuff I
find on the 'net seems old.

If you're using vs 2005, you can open the Project properties, click on
the Settings tab. You should get a link offering to create settings.
Put application and user settings in there. YOu can then use them via
Properties.Resources.Default.

HTH
Andy
Hi,
What kind of settings do you need to store?

Moty

May 30 '07 #4
What kind of settings do you need to store?

Just numbers and strings. Without getting into the description of the
program, the user has settings he/she may want to change. For
example, there are delay settings in milliseconds. It might be set to
1,000 (one second), and the user may want to change that to 10,000
(ten seconds). There's also folder location settings for files, and
many other things.

I was going to put them into an .ini file, and have the user update
the file, and have the program read the file. It is what I am working
on right now. But, is there a better way?

Titan

May 30 '07 #5
I just thought of a problem... I want the user to be able to change
settings for multiple instances of this program. It will be run on
multiple computers. So, it would be a hassle to have the user go in
and modify the settings on each program. What would be easiest, would
be to have the settings inside a .ini file (text file) that the user
modifies only once, and then copies to each instance of the program.

So, that's what I want do to. Read in an .ini file. Sorry for
jumping around. This is not typically what a software dev. would be
wanting to do.

So, is there a class in c# to read in .ini files?

~Titan

May 30 '07 #6
On May 30, 4:21 pm, titan nyquist <titan.nyqu...@gmail.comwrote:
What kind of settings do you need to store?

Just numbers and strings. Without getting into the description of the
program, the user has settings he/she may want to change. For
example, there are delay settings in milliseconds. It might be set to
1,000 (one second), and the user may want to change that to 10,000
(ten seconds). There's also folder location settings for files, and
many other things.

I was going to put them into an .ini file, and have the user update
the file, and have the program read the file. It is what I am working
on right now. But, is there a better way?

Titan
Hi,

Andy suggested the best solution for you.

The settings resource auto generates resources class that you can use
to subscribe for "SettingChanging" etc. events.
The auto generator creates an auto generated class that inherits
ApplicationSettingsBase.

Hope this helps.
Moty

May 30 '07 #7
Andy suggested the best solution for you.
>
The settings resource auto generates resources class that you can use
to subscribe for "SettingChanging" etc. events.
The auto generator creates an auto generated class that inherits
ApplicationSettingsBase.
I think that is the best solution, typcially. But now I just
discovered I need the settings store in a text file, that can be
modified by the user. I figured .ini files are the best option, and
if c# supports them with any classes it would be great.

~titan

May 30 '07 #8
"titan nyquist" <ti***********@gmail.comwrote in message
news:11*********************@p77g2000hsh.googlegro ups.com...
>I just thought of a problem... I want the user to be able to change
settings for multiple instances of this program. It will be run on
multiple computers. So, it would be a hassle to have the user go in
and modify the settings on each program. What would be easiest, would
be to have the settings inside a .ini file (text file) that the user
modifies only once, and then copies to each instance of the program.

So, that's what I want do to. Read in an .ini file. Sorry for
jumping around. This is not typically what a software dev. would be
wanting to do.

So, is there a class in c# to read in .ini files?
I don't believe there's anything built-in...

I tend to use XML documents for this, using the System.Xml namespace - this
would allow you to do the copying etc...

However, if you *really* want to use .ini files, you could do it fairly
easily with a couple of API calls:

http://www.pinvoke.net/default.aspx/...ileString.html
http://www.pinvoke.net/default.aspx/...ileString.html
--
http://www.markrae.net

May 30 '07 #9
On May 30, 4:56 pm, titan nyquist <titan.nyqu...@gmail.comwrote:
Andy suggested the best solution for you.
The settings resource auto generates resources class that you can use
to subscribe for "SettingChanging" etc. events.
The auto generator creates an auto generated class that inherits
ApplicationSettingsBase.

I think that is the best solution, typcially. But now I just
discovered I need the settings store in a text file, that can be
modified by the user. I figured .ini files are the best option, and
if c# supports them with any classes it would be great.

~titan
Hi,

XML files in general are textual files, and they are pretty
readable...

Moty

May 30 '07 #10
On May 30, 9:37 am, titan nyquist <titan.nyqu...@gmail.comwrote:
I just thought of a problem... I want the user to be able to change
settings for multiple instances of this program. It will be run on
multiple computers. So, it would be a hassle to have the user go in
and modify the settings on each program. What would be easiest, would
be to have the settings inside a .ini file (text file) that the user
modifies only once, and then copies to each instance of the program.

So, that's what I want do to. Read in an .ini file. Sorry for
jumping around. This is not typically what a software dev. would be
wanting to do.

So, is there a class in c# to read in .ini files?
The method i suggested results in a text file, which could be
modified. Although I think that's a bad idea. What if the user puts
something unexpected in there?

And its not the best way to share settings.. if you really want to
share settings, typically this is done in some sort of database. Then
it would be change once and done.

May 30 '07 #11
if you really want to
share settings, typically this is done in some sort of database. Then
it would be change once and done.
I agree. I will think about how to do this more.

~titan

May 30 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Jason Heyes | last post by:
I want to allow objects of my class to be read from an input stream. I am having trouble with the implementation. Here are the different approaches I have tried: // Version 1.0 - Default...
9
by: ALI-R | last post by:
Hi,, I have two questions : 1) Is it mandatory that config file of a desktop application must be App.config 2) Is it possible to update config file in your code?? thanks for your help. ALI
1
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; ...
3
by: Testguy | last post by:
Hi, I have been reading various messages in this group, and could not find an answer regarding what I am trying to do. At least, I could not find an easy answer. I am trying to figure out how...
2
by: Satya | last post by:
Hi, I need to read and write Configuration Settings as shown below: <MySettings> <General> <Color>Red</Color> <.Font>TimesNewRoman</Font> <Path>C</Path> </General>
8
by: paraidy | last post by:
Hi all, as from object i need to read all byte from a file example c: \myphoto.jpg and recreate the file with another name to another directory c:\photo\recreatedphoto.jpg can someone write a...
4
by: Ross | last post by:
Hello, I am trying to Read and Write to a text file on a web server using Microsoft Visual Basic 2005 Express Edition. So far I have managed to complete my testing with a local text file using...
5
by: CSharp-Jay | last post by:
So I have been programming in C# on a personal level as of lately, and am curious about something. Lately I have been experimenting around with file create/write, etc. I can open and read the...
1
by: rfarley | last post by:
Hi, I am using the pyserial module and am trying to read the serial port from an accelerometer (LIS302DL). It has an option in which you write "*debug\r\n" and then you read the data (three...
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: 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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.