C# read registry key, compare it to ini config file, if match return result under config section, do somethig else
I got below problem and with my entry level of C# please help on how to get this be done?
Scenario: 1. My registry keys:
开发者_如何学编程__DatabaseConnection
|____config1
value: username1
value: password1
|____config2
value: username2
value:password2
My ini file:
[configz]
Database=MSSQL DatabaseName= ABC Host=localhost\projects
[config1]
Database=ORACLE DatabaseName= DEF Host=server/data
[configN] Name=xxxx Age=XXXX
Question:
I want to read those registry keys compare them to those configuration sections in ini file.
If match, return those value of database/ name/ host. Connect to database server, delete the database. Repeate the process until all keys in the registry is searched and all databases deleted.
Please help! Best Regards, Duy.
For registry stuff in C# look here, particuarly the GetValue()
method.
http://msdn.microsoft.com/en-us/library/microsoft.win32.registry.aspx
public static Object GetValue(
string keyName,
string valueName,
Object defaultValue
)
For reading IniFiles see this SO post: Reading/writing an INI file
精彩评论