Answers for "c# for each file in folder"

C#
1

c# loop through files in folder

string[] files = Directory.GetFiles(txtFolderPath.Text, "*ProfileHandler.cs");
Posted by: Guest on August-28-2020
4

C# get all files in directory

//path is the path of the directory to get files from
//searchPattern is to get specific files. If you want only exe files you enter *.exe

private static IEnumerable<string> GetAllFiles(string path, string searchPattern)
        {
            return Directory.EnumerateFiles(path, searchPattern).Union(
            Directory.EnumerateDirectories(path).SelectMany(d =>
            {
                try
                {
                    return GetAllFiles(d, searchPattern);
                } catch(Exception e)
                {
                    return Enumerable.Empty<string>();
                }
            }));
        }
Posted by: Guest on May-04-2020

Code answers related to "c# for each file in folder"

C# Answers by Framework

Browse Popular Code Answers by Language