.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Storing Values in App.Config and Retriving Them using Winforms

Posted By:Hefin Dsouza       Posted Date: August 12, 2009    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  
 

This Code Sample will help you to retrive values from an App.config file.


Imports System.Configuration
Module Module1
'using App.config to store values in Key-Value pairs
Sub Main()
Dim app As New AppSettingsReader()
Console.WriteLine("Name : " & app.GetValue("name", GetType(String)))
Console.WriteLine("Password : " & app.GetValue("password", GetType(Integer))) 'Can also get values in a particular datatype
End Sub
End Module

The App.config file should have







*Note:To add an Configuration file in your Winforms project
Click on Project Menu ==> Add New Item ==>Select Application Configuration File

================================================================================
Regards Hefin Dsouza.


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend