Access a Config File
Access a Config File
Access a Config File
Access a Config File
Access a Config File
Access a Config File Access a Config File Access a Config File Access a Config File Access a Config File Access a Config File Access a Config File Access a Config File
Access a Config File Access a Config File
Access a Config File
Go Back  Xtreme Visual Basic Talk > > > Access a Config File


Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2006, 02:56 AM
mdent mdent is offline
Centurion
 
Join Date: Jun 2006
Location: Teesside, UK
Posts: 108
Default Access a Config File


Hi, I have recently written and registered a Windows Service application in VB 2005, with an app.config file with some keys and values inside the <appSettings> tags.

However, now what I need to do is create a GUI that can control those settings in that config file, so that the properties of the service can be modified. Does anyone have any ideas?

Thanks in advance.
Reply With Quote
  #2  
Old 10-19-2006, 03:08 AM
webbone's Avatar
webbone webbone is offline
Hydrogen Powered

Administrator
* Expert *
 
Join Date: Jul 2003
Location: Sacramento, CA
Posts: 6,090
Default

If you have been able (with your original program) to establish the registry entries to set your settings, what is the trouble you are having with using similar (almost identical) code to allow your program to EDIT the values you have already been able to write?
__________________
"With the appearance of the AddressOf operator, an entire industry has developed among authors illustrating how to do previously impossible tasks using Visual Basic. Another industry is rapidly developing among consultants helping users who have gotten into trouble attempting these tasks." -Dan Appleman
Reply With Quote
  #3  
Old 10-19-2006, 03:45 AM
mdent mdent is offline
Centurion
 
Join Date: Jun 2006
Location: Teesside, UK
Posts: 108
Default hm...

I think we're on crossed wires here. I have actually written a windows service with pretty much no code inside it. The other thing I did was to modify the properties of the XML-type app.config document attached to the file, with a view to later controlling them with a different application while the service was running. At no point have I actually written any code in vb to control what is in the config file - that's what I need to know! Moreover, how to write code to edit settings in a config file when that file is NOT associated with the interface I am creating.

Sorry if I have confused the situation - thanks for your help.
Reply With Quote
  #4  
Old 10-19-2006, 09:25 AM
shaul_ahuvaAccess a Config File shaul_ahuva is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Jul 2003
Location: Camp Hill, PA
Posts: 1,992
Default

Well, the new config system now allows you to save settings with the same API you use to read them.

You'll need to define an API (on your service) that allows your service to give/retrieve setting values to/from the client and forward the requests to the configuration system.
Reply With Quote
  #5  
Old 10-20-2006, 04:14 AM
mdent mdent is offline
Centurion
 
Join Date: Jun 2006
Location: Teesside, UK
Posts: 108
Default

OK didn't fancy writing an API, here is my code to read/write to an external config file in the appSettings section, with the "msg" key:

Code:
' Verify the path fileMap.ExeConfigFilename = txtPath.Text ' Open the config file config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None) ' Declare apss as the AppSettings section instance Dim apss As AppSettingsSection apss = config.GetSection("appSettings") txtDump.Text = apss.Settings(txtKey.Text).Value ' get a property of the section apss.Settings.Item("msg").Value = txtInit.Text ' Must do this to save the config file. config.Save()
Reply With Quote
  #6  
Old 10-20-2006, 07:22 AM
shaul_ahuvaAccess a Config File shaul_ahuva is offline
Ultimate Contributor

Retired Leader
* Expert *
 
Join Date: Jul 2003
Location: Camp Hill, PA
Posts: 1,992
Default

The only problem, of course, is that the service won't see the changes until it is restarted; hence, an API on the service to write the changes from the service itself.

You'll need some sort of IPC - remoting is probably the easiest. A few lines of code in the service and one line of code in the client.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Access a Config File
Access a Config File
Access a Config File Access a Config File
Access a Config File
Access a Config File
Access a Config File Access a Config File Access a Config File Access a Config File Access a Config File Access a Config File Access a Config File
Access a Config File
Access a Config File
 
Access a Config File
Access a Config File
 
-->