I am developing a web application in ASP .net using C#. I have a form that displays the contact information fetched from the database. But my requirement is - the connection string should be fetched from a file (like the properties file that we have in Java) which stores all the connection strings for different database server types. This connection string is fetched by a connection class that will use the information from the file to create a connection object usign which the database is accessed. I know how to access this file in java but since I'm new to .net, I'm stuck here. Can anyone please help me accesss this properties file??
Also, is the funtion performed by .ini file same as a properties file? So, if I use an ini file, how to I access it to retrieve the connection string ?
In java, we have Resource Bundle that can be accessed as
ResourceBundle bundle = ResourceBundle.getBundle(
then using this object you can access the key-value pair in the file.
Please help!!!!!
Deborah StoddardPosted May 6, 2015, 3:27 AM
But to my understanding a .properties file is related to a java world while .ini file is more general purpose (like in .NET, PHP, Python).
Nevertheless you can try using this .NET component for reading INI files, I believe it will successfully parse even a .properties file.
But I need to point out that in .ini files there is no mixing of key-value separator so you need to choose and use a single on, either a default '=' or ':' or ' '.