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

2021-05-19 17:28

阅读:489

标签: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


评论


亲,登录后才可以留言!