I am trying to write a small program to keep track of my movie collection but I can't seem to get the streamwriter(I think thats what its called to work). Right now I am working on writing to a text file. I had a couple of questions though, will I have to read from the text file after I write to it to keep track of the movie collection? The list will only hold information added at runtime and once the program is closed it won't save the information right? hence the need for the text file? the text file will save the info from runtime to runtime correct? I don't know where I am going wrong so could someone explain it to me? I would really appreciate it. I'm planning to work on the reading part but an example would help. I will appreciate any help. here is my code.
namespace WindowsFormsApplication1
{
public partial class frmMovies : Form
{
private List<muvie> Movies = new List<muvie>();
public frmMovies()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
muvie newmovie = new muvie()
{
newmovie = txtNew.Text.Trim(),
};
Movies.Add(newmovie);
lbMovie.Items.Add(newmovie);
Movies.Sort();
}
private void btnExit_Click(object sender, EventArgs e)
{
}
class Text
{
static void Main()
{
TextWriter tw = new StreamWriter("Movie.txt");
tw.WriteLine(newmovie);
tw.Close();
}
}
class muvie
{
public string newmovie
{ get; set;}
public override string ToString()
{
return newmovie;
}
}
}
}