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

 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

上一篇:guava学习--AsyncFunction


下一篇:sql server2017开启远程连接