|
|
- private void 导出成功点击ToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (listCount.Items.Count == 0)
- {
- MessageBox.Show("列表为空!");
- }
- else {
- List<string> list = new List<string>();
- foreach (ListViewItem item in listCount.Items)
- {
- string temp = item.SubItems[2].Text;
- list.Add(temp);
- }
- Thread thexp = new Thread(() => export(list)) { IsBackground = true };
- thexp.Start();
- }
- }
- private void export(List<string> list)
- {
- string path = AppDomain.CurrentDomain.BaseDirectory + "url_" + Guid.NewGuid().ToString() + ".txt";
- StringBuilder sb = new StringBuilder();
- foreach (string tel in list)
- {
- sb.AppendLine(tel);
- }
- System.IO.File.WriteAllText(path, sb.ToString(), Encoding.UTF8);
- txtmsg.BeginInvoke(new Action(() => {
- string temp = "文件导出成功!文件地址:" + path;
- txtmsg.AppendText(temp.SetLog());
- }));
- }
复制代码
自己写的,并且测试可用,才发上来的!!!!
就是循环listview.items,然后,装到一个list<string>集合,然后。。。。
看代码吧。
|
上一篇:c#通过GeckoFx内核,设置代理访问网站[附源码]下一篇:互联网行业让高盛态度有了新的想法
|