1.C#操作TXT文本的源码源代码!
C#操作TXT文本的源码仓库asp 源码源代码!
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,源码TRDP软件源码 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++;
//如果和你要求的输入行数匹配,显示文本,源码外呼 源码中断循环
源码etcd 源码调试if (count == numOfTextFile)
源码etcd 源码调试{
源码etcd 源码调试this.textBox1.Text = txtContent;
源码etcd 源码调试this.textBox2.Text = txtContent;
源码etcd 源码调试this.textBox3.Text = sr.ReadLine();
源码etcd 源码调试break;
源码etcd 源码调试}
源码etcd 源码调试else
源码etcd 源码调试{
源码etcd 源码调试txtContent = sr.ReadLine();
源码etcd 源码调试}
源码etcd 源码调试}
源码etcd 源码调试}
源码etcd 源码调试}
源码etcd 源码调试}
源码etcd 源码调试}
源码etcd 源码调试}
源码etcd 源码调试