469,898 Members | 1,408 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

How to write config.ini ??

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
3 5115
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
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
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.

Similar topics

33 posts views Thread by Nick Evans | last post: by
reply views Thread by Valle Hallberg | last post: by
reply views Thread by Joan Bos | last post: by
2 posts views Thread by Shaun Ram | last post: by
9 posts views Thread by ALI-R | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.