当前位置:网站首页>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
边栏推荐
- Land cover / use data product download
- Hcip fifth experiment
- Tell the truth of TS
- Build openstack platform
- The method of changing a value in the array and a value in the object of wechat applet
- Halo open source project learning (II): entity classes and data tables
- Comparison between xtask and kotlin coroutine
- cartographer_ There is no problem compiling node, but running the bug that hangs directly
- .105Location
- cv_ Solution of mismatch between bridge and opencv
猜你喜欢

MySQL_ 01_ Simple data retrieval

The JS timestamp of wechat applet is converted to / 1000 seconds. After six hours and one day, this Friday option calculates the time

SystemVerilog(六)-变量

Implementation of object detection case based on SSD

SystemVerilog (VI) - variable

Land cover / use data product download

The ultimate experience, the audio and video technology behind the tiktok

Anchor location - how to set the distance between the anchor and the top of the page. The anchor is located and offset from the top

.104History

C1小笔记【任务训练篇一】
随机推荐
MySQL 中的字符串函数
2021 Great Wall Cup WP
Summary of floating point double precision, single precision and half precision knowledge
Build openstack platform
C1小笔记【任务训练篇一】
Leak detection and vacancy filling (VIII)
JS parsing and execution process
k8s之实现redis一主多从动态扩缩容
C language input and output (printf and scanf functions, putchar and getchar functions)
Applet learning notes (I)
高德地图搜索、拖拽 查询地址
The ultimate experience, the audio and video technology behind the tiktok
Element calculation distance and event object
Anchor location - how to set the distance between the anchor and the top of the page. The anchor is located and offset from the top
The JS timestamp of wechat applet is converted to / 1000 seconds. After six hours and one day, this Friday option calculates the time
Nat Commun|在生物科学领域应用深度学习的当前进展和开放挑战
2022江西光伏展,中國分布式光伏展會,南昌太陽能利用展
I/O多路复用及其相关详解
Kubernetes 服务发现 监控Endpoints
【Appium】通过设计关键字驱动文件来编写脚本