当前位置:网站首页>C [file operation] read TXT text by line
C [file operation] read TXT text by line
2022-04-23 17:58:00 【Tomorrow is like noon】
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 WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Method 1 : According to the line read txt Text
string path = @"G:\Desktop\QuartzSideA-film_1.txt";
StreamReader sr = new StreamReader(path, Encoding.Default);
String line;
while ((line = sr.ReadLine()) != null)
{
textBox1.Text += line + "\r\n";
}
// Method 2 :
string[] strArray=File.ReadAllLines(path);
for(int i=0;i<strArray.Length;i++)
{
textBox1.Text += strArray[i]+ "\r\n";
}
}
}
}
版权声明
本文为[Tomorrow is like noon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230546376339.html
边栏推荐
- 列表的使用-增删改查
- Type judgment in [untitled] JS
- Leak detection and vacancy filling (VIII)
- Some questions some questions some questions some questions
- 2022 Shanghai safety officer C certificate operation certificate examination question bank and simulation examination
- C language implements memcpy, memset, strcpy, strncpy, StrCmp, strncmp and strlen
- Client example analysis of easymodbustcp
- 1217_ Generating target files using scons
- Implementation of k8s redis one master multi slave dynamic capacity expansion
- String function in MySQL
猜你喜欢

.104History

土地覆盖/利用数据产品下载
![C1 notes [task training chapter I]](/img/2b/94a700da6858a96faf408d167e75bb.png)
C1 notes [task training chapter I]

Implementation of image recognition code based on VGg convolutional neural network

【Appium】通过设计关键字驱动文件来编写脚本

Random number generation of C #

2022 Jiangxi Photovoltaic Exhibition, China Distributed Photovoltaic Exhibition, Nanchang Solar Energy Utilization Exhibition

C1小笔记【任务训练篇二】
![C1 notes [task training part 2]](/img/10/48f7490a6c097f2b178ae948cb2c91.png)
C1 notes [task training part 2]

On the method of outputting the complete name of typeID from GCC
随机推荐
Use of list - addition, deletion, modification and query
C# 网络相关操作
Halo open source project learning (II): entity classes and data tables
C#字节数组(byte[])和字符串相互转换
cartographer_ There is no problem compiling node, but running the bug that hangs directly
油猴网站地址
k8s之实现redis一主多从动态扩缩容
C language implements memcpy, memset, strcpy, strncpy, StrCmp, strncmp and strlen
Compilation principle first set follow set select set prediction analysis table to judge whether the symbol string conforms to the grammar definition (with source code!!!)
云原生虚拟化:基于 Kubevirt 构建边缘计算实例
2021 Great Wall Cup WP
Write a regular
MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
Submit local warehouse and synchronize code cloud warehouse
[appium] write scripts by designing Keyword Driven files
Random number generation of C #
Qtablewidget usage explanation
Go file operation
Leak detection and vacancy filling (6)
Comparison between xtask and kotlin coroutine