Hello, I am trying to save all of the items in a listbox to a file so I used the following code:

csharp Code:
  1. TextWriter tw = new StreamWriter(System.AppDomain.CurrentDomain.BaseDirectory + "listfile.txt");
  2. foreach (ListItem item in lstWords.Items)
  3.             {                
  4.                     tw.WriteLine(item.Value);              
  5.             }

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