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

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 效果

时间: 2024-08-08 17:46:55

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

C#控制台基础 streamreader 中的readline方法读取指定txt文件的第一行

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 {

C#控制台基础 streamreader 中的readline方法读取指定txt文件的所有行

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 {

Python3基础 read 方法 读取指定txt文件的前几个字符

镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.------------------------------------------ code: # 输入 # 处理 # 输出 #file 文件类型的对象 file=open(r'F:\PersonKey.txt') print(type(file)) print(file) #读文本的前五个字符并打印出来,效果是:<道德经> print(file.read(5)) #这

C++ 中使用boost::property_tree读取解析ini文件

boost 官网 http://www.boost.org/ 下载页面 http://sourceforge.net/projects/boost/files/boost/1.53.0/ 我下载的是 boost_1_53_0.tar.gz 使用系统  ubuntu 12.10 一.解压 [plain] view plaincopy tar -zxvf  boost_1_53_0.tar.gz 得到一个文件夹 boost_1_53_0,  拷贝其子目录 boost 到以下路径 [plain] vi

Java基础-输入输出-2.编写IoDemo.java的Java应用程序,程序完成的功能是:首先读取text.txt文件内容,再通过键盘输入文件的名称为iodemo.txt,把text.txt的内容存入iodemo.txt

2.编写IoDemo.java的Java应用程序,程序完成的功能是:首先读取text.txt文件内容,再通过键盘输入文件的名称为iodemo.txt,把text.txt的内容存入iodemo.txt package Test03; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import jav

C#控制台基础 streamreader与streamwriter读取一个txt中的内容写到另外一个txt中

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 {

java基础----&gt;String中的split方法的原理

这里面主要介绍一下关于String类中的split方法的使用以及原理. split函数的说明 split函数java docs的说明: When there is a positive-width match at the beginning of this string then an empty leading substring is included at the beginning of the resulting array.A zero-width match at the beg

C#控制台基础 VS2017中为控制台程序设置启动参数(string[] args)

os :windows7_x64 ide:vs2017 代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { foreach (var str in args) {

jQuery中使用data()方法读取HTML5自定义属性data-*实例

如果你使用jQuery类库,那么你可以非常愉悦的使用jquery的data()方法存取data-* 自定义属性,方法允许我们在DOM元素上绑定任意类型的数据,避免了循环引用的内存泄漏风险 主要的方法如下: 复制代码代码如下: .data( key, value ).data( obj ).data( key ).data() 从jQuery 1.4.3起, HTML 5 data- 属性 将自动被引用到jQuery的数据对象中.例如HTML: 复制代码代码如下: <div data-role =