Hi Guys,
I've been trying to do this for about 6 hours now and i'm stumped..
I want the equivalent of this in C#:
$settings = array();
foreach(file('settings.txt') as $l) $settings[]=explode(',',$l);
print $settings[0][2];
This is what i've got so far that doesn't work:
string fileName = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\" + "settings.txt";
string[,] settings;
FileStream file = null;
StreamReader sr = null;
try
{
file = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read);
sr = new StreamReader(file, Encoding.ASCII);
string[] line;
int i = 0;
do
{
line = sr.ReadLine().Split(',');
settings[i++, 0] = line[0];
} while (line != null);
file.Close();
MessageBox.Show(settings[1, 0]);
} catch (Exception err) { MessageBox.Show(err.Message); }
I get "Object reference not set to an instance of an object", any ideas would be greatly appreciated..