国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

c#簡單讀取文本的實例方法

2020-01-24 03:29:20
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:

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

namespace StreamReadWrite
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get the directories currently on the C drive.
            DirectoryInfo[] cDirs = new DirectoryInfo(@"e:/").GetDirectories();

            // Write each directory name to a file.
            using (StreamWriter sw = new StreamWriter("CDriveDirs.txt"))
            {
                foreach (DirectoryInfo dir in cDirs)
                {
                    sw.WriteLine(dir.Name);

                }
            }

            // Read and show each line from the file.
            string line = "";
            using (StreamReader sr = new StreamReader("CDriveDirs.txt"))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                }
            }
        }
    }
}   

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永清县| 江北区| 资溪县| 达尔| 仁怀市| 叶城县| 海原县| 阳西县| 芜湖市| 怀集县| 广州市| 景洪市| 东光县| 牟定县| 宜都市| 安丘市| 磴口县| 黄浦区| 石景山区| 恭城| 西峡县| 广灵县| 开封县| 芷江| 九江县| 五寨县| 连平县| 治县。| 广东省| 延寿县| 灵宝市| 太和县| 新民市| 临汾市| 天柱县| 磐安县| 新营市| 西乌珠穆沁旗| 灵宝市| 眉山市| 百色市|