国产探花免费观看_亚洲丰满少妇自慰呻吟_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);
                }
            }
        }
    }
}   

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 玉环县| 微博| 卫辉市| 威宁| 郯城县| 大城县| 溆浦县| 陇南市| 客服| 勐海县| 静海县| 绥棱县| 南宁市| 赤城县| 商都县| 吉安市| 广元市| 长海县| 巨鹿县| 孙吴县| 定州市| 柳州市| 海城市| 施甸县| 上犹县| 华亭县| 纳雍县| 融水| 临桂县| 昆山市| 安顺市| 黔南| 芒康县| 馆陶县| 四子王旗| 广安市| 依兰县| 革吉县| 旬邑县| 甘孜| 读书|