Hello, I am trying to save all of the items in a listbox to a file so I used the following code:
csharp Code:
TextWriter tw = new StreamWriter(System.AppDomain.CurrentDomain.BaseDirectory + "listfile.txt"); foreach (ListItem item in lstWords.Items) { tw.WriteLine(item.Value); }
That does not work, I don't know what to use for ListItem in the foreach. I tried doing a loop at first, and had no luck, so I searched around on google for a while and got the above code, but I changed it a little for what I needed and It doesn't work. I am used Visual Basic where you just do a simple loop. How do I do this?
Thanks








Reply With Quote