码迷,mamicode.com
首页 > Windows程序 > 详细

C# get files and write the files full name in txt

时间:2019-10-18 16:14:21      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:str   pat   filename   fstream   stream   files   foreach   ati   string   

 static void GetAllFiles()
        {
            string path = "filepath";
            var allFiles = Directory.GetFiles(path);
            string fileName = "file.txt";

            using (FileStream fStream = File.Create(fileName))
            { }

            using (FileStream fStream = File.Create("file.txt"))
            {
                using (StreamWriter writer = new StreamWriter(fStream, Encoding.UTF8))
                {
                    foreach (var file in allFiles)
                    {
                        writer.WriteLine(file);
                    }
                }
            }
        }

 

C# get files and write the files full name in txt

标签:str   pat   filename   fstream   stream   files   foreach   ati   string   

原文地址:https://www.cnblogs.com/Fred1987/p/11698318.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!