I think im being an idiot here, but im new to C#. If i run the following
StreamReader sr = new StreamReader(@"./common/hostname");
string line= sr.ReadLine();
sr.Close();
the code executes fine, but if i run the following
// lstboxSites.Text == foo
StreamReader sr = new StreamReader(string.Format(@"./site/{0}", lstboxSites.Text));
string line = sr.ReadLine();
sr.close()
this raises an error for "Illegal characters in path", if i try and type in the directory itself it works
StreamReader sr = new StreamReader(@"./site/foo");
string line = sr.ReadLine();
sr.close()
Have i been an idiot ? if i output the middle section to messagebox.show() then its correct
Ideal working example -- edited
// user clicks on list box item, read value on click
StreamReader sr = new StreamReader(string.Format(@"./site/{0}", lstboxSites.Text));
string line = sr.ReadLine();
sr.Close();
// write to a text box
txtFakeBox.Text = line;