C#读取txt文件

作者: 张中华 | 来源:发表于2017-12-03 23:38 被阅读41次

继上一篇文章写到解压文件,将一个txt文件手动压缩成.rar文件,后用程序解压,现在再写一个程序将.txt文件内的内容读出来。
学习参考网址:
https://www.cnblogs.com/akwwl/p/3240813.html

读出.txt每一行的信息
代码:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ReadText
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamReader sr = new StreamReader("F:\\TestUnZip\\testUnzip.txt", Encoding.Default);
            String line;
            while ((line = sr.ReadLine()) != null)
            {
                Console.WriteLine(line.ToString());
            }
            Console.ReadLine();
        }
    }
}

测试结果:


读取txt每一行信息

相关文章

  • C#读取txt文件

    继上一篇文章写到解压文件,将一个txt文件手动压缩成.rar文件,后用程序解压,现在再写一个程序将.txt文件内的...

  • 读取txt文件

    """ 读取txt文件txt文件使我们经常操作的文件类型,Python提供了以下几种读取txt文件的方法。read...

  • 读写txt/rtf文件

    目录:1、txt文件写入2、txt文件读取3、rtf文件读取4、NSString转换成其他类型数据方法 1、txt...

  • 长知识系列 - 收藏集 - 掘金

    SpringBatch 读取 txt 文件并写入数据库 - 后端 - 掘金SpringBatch 读取 txt 文...

  • 长知识 - 收藏集 - 掘金

    SpringBatch 读取 txt 文件并写入数据库 - 后端 - 掘金SpringBatch 读取 txt 文...

  • Python中List的存储和读取

    List的存储,存储为txt类型 List的读取,读取txt类型文件 完成!

  • Txt文件读取《一》

    使用 TextAsset读取txt文件

  • R数据读写

    csv文件读写 txt文件读写 读取excel文件 转成csv文件读取(逗号分隔) 专程prn文件读取(空格分隔)...

  • 利用Python处理Excel数据

    读取数据 读取x.xlsx文件 读取文件夹 读取txt文件 读取csv格式Excel表 写入excel 显示数据 ...

  • R语言 读取文件

    1. R读取txt文件 使用R读取txt文件直接使用read.table()方法进行读取即可,不需要加载额外的包。...

网友评论

    本文标题:C#读取txt文件

    本文链接:https://www.haomeiwen.com/subject/fbttixtx.html