当前位置:网站首页>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
边栏推荐
- 列錶的使用-增删改查
- .105Location
- On the method of outputting the complete name of typeID from GCC
- Client example analysis of easymodbustcp
- Amount input box, used for recharge and withdrawal
- 2022年茶艺师(初级)考试模拟100题及模拟考试
- Implementation of image recognition code based on VGg convolutional neural network
- 开源按键组件Multi_Button的使用,含测试工程
- Sword finger offer 22 The penultimate node in the linked list - speed pointer
- Nat commun | current progress and open challenges of applied deep learning in Bioscience
猜你喜欢
Click Cancel to return to the previous page and modify the parameter value of the previous page, let pages = getcurrentpages() let prevpage = pages [pages. Length - 2] / / the data of the previous pag
k8s之实现redis一主多从动态扩缩容
C1 notes [task training part 2]
Auto.js 自定义对话框
2022 tea artist (primary) examination simulated 100 questions and simulated examination
On the problem of V-IF display and hiding
Go对文件操作
Summary of floating point double precision, single precision and half precision knowledge
极致体验,揭晓抖音背后的音视频技术
C network related operations
随机推荐
On the method of outputting the complete name of typeID from GCC
String function in MySQL
Thirteen documents in software engineering
Chrome浏览器的跨域设置----包含新老版本两种设置
SystemVerilog (VI) - variable
开源按键组件Multi_Button的使用,含测试工程
Kubernetes service discovery monitoring endpoints
C#字节数组(byte[])和字符串相互转换
JS high frequency interview questions
.105Location
2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
386. Dictionary order (medium) - iteration - full arrangement
Go的Gin框架学习
C network related operations
Flask项目的部署详解
QTableWidget使用讲解
undefined reference to `Nabo::NearestNeighbourSearch
The ultimate experience, the audio and video technology behind the tiktok
.104History
[appium] write scripts by designing Keyword Driven files