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,源码表白源码是什么 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++;
//如果和你要求的输入行数匹配,显示文本,源码开发语音对讲源码中断循环
源码电商源码交付if (count == numOfTextFile)
源码电商源码交付{
源码电商源码交付this.textBox1.Text = txtContent;
源码电商源码交付this.textBox2.Text = txtContent;
源码电商源码交付this.textBox3.Text = sr.ReadLine();
源码电商源码交付break;
源码电商源码交付}
源码电商源码交付else
源码电商源码交付{
源码电商源码交付txtContent = sr.ReadLine();
源码电商源码交付}
源码电商源码交付}
源码电商源码交付}
源码电商源码交付}
源码电商源码交付}
源码电商源码交付}
源码电商源码交付}
源码电商源码交付