How can i save contents of a listbox to a text or word file using C#
How can i save contents of a listbox to a text or word file using C#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Dec 26, 2009, 10:15 AM
Hiren SoniPosted Dec 25, 2009, 8:35 PM
to save in c drive and
give example of item which is in you listbox
Dave ChikaPosted Dec 25, 2009, 6:22 PM
Dave ChikaPosted Dec 25, 2009, 6:15 PM
Hello, Kirtan.ur code is working but the data am storing gotten from Eight (8) which are arranged in colums but ur code mixes evertin up.
Dave ChikaPosted Dec 25, 2009, 6:00 PM
Kirtan PatelPosted Dec 25, 2009, 5:42 PM
// Writing List box content to txt File
using System.IO;
private void button1_Click(object sender, EventArgs e)
{
string filename = "data.txt";
string listboxData = "";
foreach (string str in listBox1.Items)
{
listboxData += str + "\n";
}
File.WriteAllText(filename, listboxData);
}