By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

How to write config.ini ??

P: n/a
Can I write a file like config.ini which store the server-name, userid &
password,
So, my application can read the config.ini file and get the server - name,

Does my concept is correct ?
If yes, do any web site can provide the sample of such file or provide
tutorial ??
For my current stage, i got a class object and assign the server-name to a
property, even form will call this class object.
Please give some advice.
p.s - It is my 1st time to do vb.net deployment

--
..
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

http://msdn.microsoft.com/library/de...et02122002.asp

http://msdn.microsoft.com/library/de...et07082003.asp

Ken
----------------
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Can I write a file like config.ini which store the server-name, userid &
password,
So, my application can read the config.ini file and get the server - name,

Does my concept is correct ?
If yes, do any web site can provide the sample of such file or provide
tutorial ??
For my current stage, i got a class object and assign the server-name to a
property, even form will call this class object.
Please give some advice.
p.s - It is my 1st time to do vb.net deployment

--
..

Nov 21 '05 #2

P: n/a
Hi Agnes

You are thinking along the right lines - the .ini file is now a .config
file: for an app like Test.exe, the file would be called Test.exe.config.

However: you must consider the security impact of data like userid /
password being stored in the file...

As a quick intro, in Visual Studio .NET, you create a file called app.config
in your solution (add a new Application Configuration file to the solution,
and this will be done for you). Then the build process will automatically
change the filename to the correct one for you.

The config file uses XML - the easiest way to get started using dynamic
properties is in the design time view, select a control (say your Form), and
scroll to the top of the properties window - select Dynamic Properties, and
click on the ... button. Select Text, and you will see that your app.config
file will have been modified like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="Form1.Text" value="Form1" />
</appSettings>
</configuration>

You will also notice that the text property in the properties window will
have a small blue glyph by it indicating that it is a dynamic property, and
the following code will have been added into the design time environment for
you too.

Dim configurationAppSettings As System.Configuration.AppSettingsReader = New
System.Configuration.AppSettingsReader
Me.Text = CType(configurationAppSettings.GetValue("Form1.Tex t",
GetType(System.String)), String)

When you build the application, you will find that you can change the
..config file, and when you start your application, it will read the
information from the config file.

HTH

Nigel Armstrong

"Agnes" wrote:
Can I write a file like config.ini which store the server-name, userid &
password,
So, my application can read the config.ini file and get the server - name,

Does my concept is correct ?
If yes, do any web site can provide the sample of such file or provide
tutorial ??
For my current stage, i got a class object and assign the server-name to a
property, even form will call this class object.
Please give some advice.
p.s - It is my 1st time to do vb.net deployment

--
..

Nov 21 '05 #3

P: n/a
Thanks Nigel, I will try to build a small application to test the config.
Thanks Ken, I will go through the msdn web site

--
..
"Nigel Armstrong" <Ni************@discussions.microsoft.com> bl
news:29**********************************@microsof t.com g...
Hi Agnes

You are thinking along the right lines - the .ini file is now a .config
file: for an app like Test.exe, the file would be called Test.exe.config.

However: you must consider the security impact of data like userid /
password being stored in the file...

As a quick intro, in Visual Studio .NET, you create a file called app.config in your solution (add a new Application Configuration file to the solution, and this will be done for you). Then the build process will automatically
change the filename to the correct one for you.

The config file uses XML - the easiest way to get started using dynamic
properties is in the design time view, select a control (say your Form), and scroll to the top of the properties window - select Dynamic Properties, and click on the ... button. Select Text, and you will see that your app.config file will have been modified like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="Form1.Text" value="Form1" />
</appSettings>
</configuration>

You will also notice that the text property in the properties window will
have a small blue glyph by it indicating that it is a dynamic property, and the following code will have been added into the design time environment for you too.

Dim configurationAppSettings As System.Configuration.AppSettingsReader = New System.Configuration.AppSettingsReader
Me.Text = CType(configurationAppSettings.GetValue("Form1.Tex t",
GetType(System.String)), String)

When you build the application, you will find that you can change the
.config file, and when you start your application, it will read the
information from the config file.

HTH

Nigel Armstrong

"Agnes" wrote:
Can I write a file like config.ini which store the server-name, userid &
password,
So, my application can read the config.ini file and get the server - name,
Does my concept is correct ?
If yes, do any web site can provide the sample of such file or provide
tutorial ??
For my current stage, i got a class object and assign the server-name to a property, even form will call this class object.
Please give some advice.
p.s - It is my 1st time to do vb.net deployment

--
..

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.