Using Configuration Files with VB.net

mtbballer

Newcomer
Joined
Jul 29, 2003
Messages
3
I have compiled a simple application (host & client) that allows me to control my windows media player with my pocket PC. In the application, the port number is hardcoded into the program.

How do I setup and import a configuration file that will allow me to modify this port number without having to recode and recompile the program? (i.e. a flat file that has an entry like "soapport=9000")
 
You need to create a configuration file in XML.
The file is exename.config i.e. for a program called woof it would be called woof.exe.config

The gubbins goes in:
Code:
<configuration>
   <appSettings>
      <!-- Your settings go here... -->
   </appSettings>
</configuration>
 
My woof.exe.config (for woof.exe) is located in the bin folder.
Everytime I run or compile the project, the file disappears.
In addition, the appSettings values return "" (no error).
Are there any obscure settings that control this?
 
The VS IDE takes any file in your project called App.config and copies it into the \bin directory as ecename.exe.config when you compile a project.
 
Back
Top