66问答网
所有问题
c#中怎么将listbox中的内容写到txt中
如题所述
举报该问题
推荐答案 2017-04-12
先把listbox每一项添加到一个集合中
在把这个字符串数组写入文件
System.IO.File.WriteAllLines(文件名,listBox1.Items.Select(x=>x.ToString()).ToArray());
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://66.wendadaohang.com/zd/siiD229xs2nx2ivv2s.html
相似回答
C#listbox
中将数据写入到
txt中
答:
其实很简单的楼主,首先引入System. io你在一个按钮的点击事件中写如下代码哈 StreamWriter writer = new StreamWriter(@"F:\123.
txt
", true);// 前面的@是告诉编译器后面的字符串是表示地址 for (int i = 0; i <
listBox
1.Items.Count;i++ )//循环遍历
listbox的
所有items哈 writer.Wr...
VS里面中
C#如何将
输入到
listBox中的
数据导出到桌面
txt
文本中?
答:
System.IO.File.WriteAllText(@"C:\Users\Administrator\Desktop\1.
txt
", string.Join(Environment.NewLine,
listBox
1.Items.Cast<string>()));附运行效果图:
c#中如何将listbox中的内容
添加到textbox中
答:
①确保
listbox中
存储的文本名称,包括其所在完整路径 ②在listbox的SelectedIndexChanged事件中,添加代码:string[] contents=System.IO.File.ReadAllLines(@listbox.selectedItem);foreach(string temp in contents){ textbox.appendText(temp);}
急!!!
C#中
的
listbox 中的
文字
内容怎么
保存成文件.
txt
或其他形式??
答:
string result =
listbox
.text;//或者你listbox里面有多个item,这里就用个foreach把他们都
写到
result里 region 文本写入 using (StreamWriter sw = File.CreateText(@"c:\result1.
txt
")){//成功 sw.WriteLine(result);sw.Flush();} //更简单 //File.WriteAllText(@"c:\result2.txt", result...
C#中
我想
把listbox
里面
的内容写到
一个文件,
怎么
编程
答:
i <
listBox
1.Items.Count; i++){ str += listBox1.Items[i].ToString()+"\r\n";} FileStream fs = new FileStream("c:\\1.
txt
", FileMode.OpenOrCreate);StreamWriter sw = new StreamWriter(fs);sw.Write(str);sw.Flush();sw.Close();fs.Close();MessageBox.Show("ok");...
C#listBox
赋值给textbox
答:
<asp:ListItem Text"思己之过" Value="思己之过" /> <asp:ListItem Text"悔在衙" Value="悔在衙" /> </asp:
ListBox
> 赋值代码如下:
txt
Name .Text = lstType.SelectedItem.Text;或 txtName .Text = lstType.SelectedItem.Value;希望对您有所帮助。参考资料:悔过衙,日日发网络,思己之...
大家正在搜
相关问题
在C#中如何将listBox1.Items中的内容输出?
怎么用c#语句向一个listbox表中写入数据
c#中如何将txt中的部分内容添加到listbox中
C#中listbox怎么读入文本?
C# 读取Txt文件内容 显示到checkListBox控件...
C#中listbox中的文本怎么获取?
C#如何给listbox中添加值
C#如何将listbox控件中的文本导出 .net 2.0