How to create dynamically a multi-dimensional string array

  • Thread starter Thread starter G-Oker
  • Start date Start date
G

G-Oker

Guest
Hello,

I am reading a 3rd party programs INI file to get data out of it.

the ini file looks like this

[DatabaseInfo]
Server=localhost
Database=testdb
Name=Company1
TServer=
TDatabase=test_training
UServer=
Cloud=2
country=English

[Remote]
Entries=11
Name1=Company2
Server1=6.6.6.6
Database1=test2db
TServer1=6.6.6.6
TDatabase1=test2_training
Remote1=
TRemote1=
Name2=Company3
Server2=8.8.8.8
Database2=test3db
TServer2=
TDatabase2=
Remote2=
TRemote2=
CloudDatabase2=

etc

I am using the following method to locate the ini file

public static string getIniValue(string MainSection, string key, string defaultValue)
{
IniFile inif = new IniFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles) + @"\progFolder\data.ini");
string value = "";
value = (inif.IniReadValue(MainSection, key, defaultValue));
return value;
}


and I can get eh "entries" line

var _dataINIEntries = getIniValue("Remote", "Entries", "");


ie 11


but what I need to create now is a 2D string array (name server) or each entrie, so I can then reference the Namein a drop down combo box, and reference the associated server elsewhere.

I've tried to do this in a

string[,] Names2D = Create2DArray(10, 10);//Two-dimensional string array
List<string> twoDimensional = new List<string>();

for (int i = 1; i < Convert.ToInt32(_dataINIEntries); i++)
{
twoDimensional = getIniValue("Name"+i, "Server" + i, "Database" + i);
comboBox3.Items.Add(twoDimensional);
}



but is fails with "null values.


can someone show me what I need to do please ?


thank you

Continue reading...
 
Back
Top