p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   C# 2005 (http://p2p.wrox.com/forumdisplay.php?f=138)
-   -   User Setup, Help needed! (http://p2p.wrox.com/showthread.php?t=56358)

alien13 April 6th, 2007 11:54 PM

User Setup, Help needed!
 
Hello, I'm new to C#, I started changing my program from AutoIt to C# last night, and I almost have the major features done.

There is one big problem that I am having at the moment. I don't know how to have an XML/INI/Etc file as the config file.
In my AutoIt version, I use a config.ini file that saves all the information.

My program is basically a hub. The user chooses what programs and websites they want to have in the program. They do this through the setup window. When they click the save button, everything gets written to the ini file.
Also, because there is an option for 5 programs they have to write a name in, and when they click save, the name is shown in a label.

So basically everything is written and read from this ini file. eg. the buttons and labels.

Here is my program so you know what I mean: hxxp://www.alien13.jumbahost.com/Launcher/WoW/CurrentVersion/Setup.rar

Is there a way to do this with C#. I have got the Setup window exactly the same, I just need to make it write to an XML or INI or whatever file and then have that information be read back so that the Launch buttons launch the programs selected, the names are shown next to each launch button, the website buttons launch the default browser and the written in website as well as display the sites name, and the Login button Launch world of warcraft and write in the username and password.

I hope that makes sense, If not just play around with my program above and you should get what I mean. Load in some programs and websites, click save and restart it. Go through the tabs on the main window and you will see how everything fits into place :)

Thanks alien13

New to C#
Known Languages:
AutoIt
English
German(Not much, but a bit)

planoie April 8th, 2007 10:19 PM

I typically use object serialization to deal with config settings (whether they are readonly or read/write). Fortunately, the .NET framework provides some very easy methods for serializing and deserializing objects to and from XML. You can create a class that holds your settings (single global settings as well as setting collections/lists, such as your program list). Then you just serialize an instance of the class to disk. You don't have to write any code that processes XML directly, just let the framework do it.

Take a look at the XmlSerializer class to get an idea of where to start:

http://msdn2.microsoft.com/en-us/lib...erializer.aspx

-Peter

alien13 April 10th, 2007 06:15 AM

Hi Peter,

Thank you for the reply!
I'll have a look at the XmlSerializer class and see if I will be able to figure it out.

alien13(Nathan)

New to C#
Known Languages:
AutoIt
English
German(Not much, but a bit)


All times are GMT -4. The time now is 10:11 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.