views:

38

answers:

1

Hello,

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
  1. 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.

A: 

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: http://stackoverflow.com/questions/217902/reading-writing-ini-file-in-c

kyndigs