Help me.


Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 8, 2012, 1:40 PM EST
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 6, 2012, 5:21 PM EST
Try this...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace listbox_copy
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
listBox1.Items.Add("a");
listBox1.Items.Add("b");
listBox1.Items.Add("c");
}
private void button1_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamWriter sw = new StreamWriter(saveFileDialog1.FileName);
foreach (object item in listBox1.Items)
sw.WriteLine(item.ToString());
sw.Close();
MessageBox.Show("Listbox items copied");
}
}
}
}
Thanks
Csharp Ninja96 reputationPosted Feb 8, 2012, 1:15 PM EST
Csharp Ninja96 reputationPosted Feb 8, 2012, 2:10 PM EST
Cheers
Sam HobbsRank #108 · 20.5K reputationPosted Feb 9, 2012, 9:28 PM EST