Well I got the loading an array from text, it loads every line and pops it into an array. Now my question is how would I go through every thing in the array and save it into a text file? I know how to write to a text file like this.
StreamWriter tw = new StreamWriter(file);
tw.WriteLine("text");
tw.Close();
Now how to I go through every item in my array? So like I have this array urls which holds the users bookmarks, so when clicked it'll navigate to that website. Now it works and all but I need it so when people add or remove a bookmark it updates the file that holds all the data. So any idea?
StreamWriter tw = new StreamWriter(file);
foreach (string line in array)
{
tw.WriteLine(line + "\n");
}
tw.Close();
the +"\n" is unnecessary each time the WriteLine Method is called it automatically writes to a new line
Right. Well noticed. And even if it was Write(), it had to be "\r\n". That was the Ruby in me up there. xD
okay now how would I do it for every item in the combobox? I tried what blizz said in the c# help topic, but I'm not sure how to get it.
not sure what to do so thanks guys for the help.
StreamWriter tw = new StreamWriter(file);
foreach (object item in combobox.Items)
{
tw.WriteLine((string)item);
}
tw.Close();
You need to cast it into a string since all items in the combobox are cast to object.
Thanks guys it works all right now *marks as resolved*