1.C#操作TXT文本的源码源代码!
C#操作TXT文本的源码透明网页源码源代码!
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 OutputText
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
}
void Form1_Load(object sender,源码nginx源码含义 EventArgs e)
{
this.btnShow.Click += new EventHandler(btnShow_Click);
}
void btnShow_Click(object sender, EventArgs e)
{
// 判断输入的行数
string input = this.txtInput.Text.Trim();
//用于读文本的时候记数
int numOfTextFile;
// int.TryParse验证输入的是不是行数
if (int.TryParse(input, out numOfTextFile))
{
//StreamReader 打开文件
using(StreamReader sr = new StreamReader(@"D:\text.txt"))
{
int count=0;
// ReadLine 读一行
string txtContent = sr.ReadLine();
while (txtContent != null)
{
//读一行记一下数
count++;
//如果和你要求的输入行数匹配,显示文本,源码cygwin源码安装中断循环
源码gcc源码获取if (count == numOfTextFile)
源码gcc源码获取{
源码gcc源码获取this.textBox1.Text = txtContent;
源码gcc源码获取this.textBox2.Text = txtContent;
源码gcc源码获取this.textBox3.Text = sr.ReadLine();
源码gcc源码获取break;
源码gcc源码获取}
源码gcc源码获取else
源码gcc源码获取{
源码gcc源码获取txtContent = sr.ReadLine();
源码gcc源码获取}
源码gcc源码获取}
源码gcc源码获取}
源码gcc源码获取}
源码gcc源码获取}
源码gcc源码获取}
源码gcc源码获取}
源码gcc源码获取2024-12-26 00:45
2024-12-26 00:41
2024-12-26 00:36
2024-12-26 00:28
2024-12-25 23:55
2024-12-25 23:47
2024-12-25 23:21
2024-12-25 22:37