码迷,mamicode.com
首页 > Windows程序 > 详细

C#控制台基础 streamreader 中的readtoend方法读取指定txt文件

时间:2016-10-11 21:00:18      阅读:527      评论:0      收藏:0      [点我收藏+]

标签:

1 代码

 1 using System;
 2 using System.Collections.Generic;
 3 using System.IO;
 4 using System.Linq;
 5 using System.Text;
 6 using System.Threading.Tasks;
 7 
 8 namespace ConsoleApplication4
 9 {
10     class Program
11     {
12         static void Main(string[] args)
13         {
14             using (StreamReader sReader = new StreamReader(@"1.txt", Encoding.Default))
15             {
16                 //读到末尾
17                 string content = sReader.ReadToEnd();
18                 Console.WriteLine(content);
19             }
20             Console.ReadKey();
21         }
22     }
23 }

 

 

2 txt文件

技术分享

 

 

3 效果

技术分享

C#控制台基础 streamreader 中的readtoend方法读取指定txt文件

标签:

原文地址:http://www.cnblogs.com/jinlingzi/p/5950470.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!