1
Answer

Saving with Listbox

kristanbain

kristanbain

21y
2.6k
1
Hey everyone!! I hope that someone can give me a hand here. I am trying to save to a file but inside file needs the content of a list box. Here is the code I am using private void btnSave_Click_1(object sender, System.EventArgs e) { try { SaveFileDialog Save = new SaveFileDialog(); Save.Filter="txt files (*.txt)|*.txt|All files (*.*)|*.*" ; if (Save.ShowDialog()==DialogResult.OK) { string fileName= Save.FileName; FileStream fs = new FileStream(fileName,FileMode.Create, FileAccess.Write, FileShare.None); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(//??????????????????????? WHAT GOES HERE); //NEED CODE FOR WRITELINE!! sw.Flush(); sw.Close(); } } catch(Exception ex) { Console.WriteLine(ex.StackTrace); } I hope someone can help!! Thanks a lot!
Answers (1)