当前位置:网站首页>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
边栏推荐
- 2022制冷与空调设备运行操作判断题及答案
- Build openstack platform
- C1 notes [task training part 2]
- Realsense selection comparison d455 d435i d415 t265 3D hardware comparison
- 一些问题一些问题一些问题一些问题
- 2022 Shanghai safety officer C certificate operation certificate examination question bank and simulation examination
- Oil monkey website address
- C language input and output (printf and scanf functions, putchar and getchar functions)
- Detailed deployment of flask project
- MySQL进阶之索引【分类,性能分析,使用,设计原则】
猜你喜欢
MySQL_01_简单数据检索
1217_ Generating target files using scons
Nat commun | current progress and open challenges of applied deep learning in Bioscience
编译原理 求first集 follow集 select集预测分析表 判断符号串是否符合文法定义(有源码!!!)
关于gcc输出typeid完整名的方法
EasymodbusTCP之clientexample解析
极致体验,揭晓抖音背后的音视频技术
Romance in C language
Halo open source project learning (II): entity classes and data tables
Detailed deployment of flask project
随机推荐
Cross domain settings of Chrome browser -- including new and old versions
Error in created hook: "referenceerror:" promise "undefined“
The JS timestamp of wechat applet is converted to / 1000 seconds. After six hours and one day, this Friday option calculates the time
Detailed deployment of flask project
Leak detection and vacancy filling (VIII)
MySQL_ 01_ Simple data retrieval
SQL optimization for advanced learning of MySQL [insert, primary key, sort, group, page, count]
2022江西光伏展,中國分布式光伏展會,南昌太陽能利用展
vite配置proxy代理解决跨域
cv_ Solution of mismatch between bridge and opencv
The ultimate experience, the audio and video technology behind the tiktok
MySQL进阶之索引【分类,性能分析,使用,设计原则】
Gets the time range of the current week
I / O multiplexing and its related details
C language array processing batch data
Gaode map search, drag and drop query address
Utilisation de la liste - Ajouter, supprimer et modifier la requête
YOLOv4剪枝【附代码】
This point in JS
Cloud native Virtualization: building edge computing instances based on kubevirt