ChinhDo.Transactions.TxFileManager.GetFiles C# (CSharp) Method

GetFiles() public method

Gets the files in the specified directory.
public GetFiles ( string path, FileEventHandler handler, bool recursive ) : void
path string The directory to get files.
handler FileEventHandler The object to call on each file found.
recursive bool if set to true, include files in sub directories recursively.
return void
        public void GetFiles(string path, FileEventHandler handler, bool recursive)
        {
            foreach (string fileName in Directory.GetFiles(path))
            {
                bool cancel = false;
                handler(fileName, ref cancel);
                if (cancel)
                {
                    return;
                }
            }

            // Check subdirs
            if (recursive)
            {
                foreach (string folderName in Directory.GetDirectories(path))
                {
                    GetFiles(folderName, handler, recursive);
                }
            }
        }