C#读取文本文件到listbox组件的方法
作者:小萝莉 时间:2022-11-18 02:54:05
本文实例讲述了C#读取文本文件到listbox组件的方法。分享给大家供大家参考。具体实现方法如下:
private void AddTxtToLst(string path,ListBox lst)
{
StreamReader file = new StreamReader(path,Encoding.Default);
string s = "";
while (s != null)
{
s = file.ReadLine();
if (!string.IsNullOrEmpty(s))
lst.Items.Add(s);
}
file.Close();
}
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,文本文件,listbox
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
idea中将单个java类导出为jar包文件的方法
2022-08-18 11:15:55
![](https://img.aspxhome.com/file/2023/7/71847_0s.png)
详解JAVA Spring 中的事件机制
2022-01-13 05:26:33
Spring Boot和Thymeleaf整合结合JPA实现分页效果(实例代码)
2023-11-25 07:05:15
![](https://img.aspxhome.com/file/2023/1/60051_0s.png)
Java中ReentrantLock4种常见的坑
2021-09-26 10:51:46
![](https://img.aspxhome.com/file/2023/3/61133_0s.webp)
android中UI主线程与子线程深入分析
2022-02-06 15:19:25
SpringBoot整合Mybatis实现多数据源配置与跨数据源事务实例
2023-06-29 23:47:34
详解AndroidStudio JNI +Gradle3.0以上JNI爬坑之旅
2021-09-01 05:45:04
![](https://img.aspxhome.com/file/2023/2/88102_0s.jpg)
详解SpringBoot定制@ResponseBody注解返回的Json格式
2023-07-26 13:47:02
C#如何操作Excel数据透视表
2021-09-01 20:18:42
![](https://img.aspxhome.com/file/2023/1/65221_0s.png)
Spring3 整合MyBatis3 配置多数据源动态选择SqlSessionFactory详细教程
2023-03-21 21:22:27
![](https://img.aspxhome.com/file/2023/6/61816_0s.png)
springboot项目以jar包运行的操作方法
2023-11-10 07:47:43
![](https://img.aspxhome.com/file/2023/8/59328_0s.png)
Java单例模式分析
2023-11-16 03:17:06
Java获取UTC时间的方法详解
2022-03-24 13:50:50
![](https://img.aspxhome.com/file/2023/5/94345_0s.jpg)
Java调用第三方http接口的常用方式总结
2023-11-06 22:47:24
Java中的守护线程问题
2023-09-13 11:49:23
![](https://img.aspxhome.com/file/2023/7/75427_0s.png)
移动开发Spring Boot外置tomcat教程及解决方法
2023-08-25 11:47:33
如何创建SpringBoot项目
2022-03-26 16:06:37
![](https://img.aspxhome.com/file/2023/7/68167_0s.png)
C#使用ScrapySharp快速从网页采集数据
2021-08-14 09:25:14
![](https://img.aspxhome.com/file/2023/8/71728_0s.png)
Java设计模式之原型设计示例详解
2023-08-04 04:53:35
![](https://img.aspxhome.com/file/2023/1/74981_0s.png)
swagger添加权限验证保证API(接口)安全性(两种方法)
2023-11-27 18:58:33
![](https://img.aspxhome.com/file/2023/5/60255_0s.png)