C#_StreamReader讀取文本文件

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

namespace CShapeTest
{
    class Start
    {
        static void Main(string[] args)
        {
            // StreamReader讀取文本文件

            // 讀取一行
            //StreamReader reader = new StreamReader("hand.png");
            //string str = reader.ReadLine();
            //Console.WriteLine(str);
            //reader.Close();

            // 讀取到結束
            //StreamReader reader = new StreamReader("Skill.json");
            //string str = reader.ReadToEnd();
            //Console.WriteLine(str);
            //reader.Close();

            // 讀取一個字符
            StreamReader reader = new StreamReader("Skill.json");
            char ch = (char)reader.Read();
            Console.WriteLine(ch);
            reader.Close();

            Console.ReadLine();
        }
    }
}

發佈了260 篇原創文章 · 獲贊 7 · 訪問量 22萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章