|
Okay, so I am making a web browser.
I have a StreamWriter that writes the current url to a file. I also I have a StreamReader that (on form load) reads the file and populates my combobox with the urls. The problem is if I put the StreamWriter in the go button click method it will close and I will only write 1 line (if there are multiple urls it only writes the last one -well actually it writes all the urls the problem is it writes over the previous url). If I put the StreamWriter in the declarations I get a system IO Exception, because my StreamReader already has access the the file (the StreamWriter successfully writes multiple urls if I disable the StreamReader). So I need to find either a place for the StreamReader or StreamWriter...
Wait....
Fuck yes! My first use of an array that worked!
C# code //Way up top
ArrayList urllist = new ArrayList();
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
StreamWriter sw = new StreamWriter("history.txt");
foreach (string temp in urllist)
{
sw.WriteLine(temp);
}
sw.Close();
sw.Dispose();
}
|
|
|
|
≡
|
2010 Jan 28 at 06:16 UTC
— Ed. 2010 Jan 28 at 06:39 UTC
|
|