欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c#簡(jiǎn)單讀取文本的實(shí)例方法

 更新時(shí)間:2013年04月08日 17:18:51   作者:  
c#簡(jiǎn)單讀取文本的實(shí)例方法,需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

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);
                }
            }
        }
    }
}   

相關(guān)文章

最新評(píng)論