あなたがやろうとしていることを明確にできますか?
Marc が提供するサンプル コードでは、検出されたすべてのファイルに対して呼び出されるアクションを提供する必要があります。したがって、そのアクションの呼び出しは、そのファイルの処理を表します。
フォルダー内のすべてのファイルとサブフォルダーがいつ処理されたかを判断する方法を探している場合は、コードを変更して 2 番目のアクションを追加する必要があります。このようなもの:
using System;
using System.IO;
static class Program
{
static void Main()
{
string path = ""; // TODO
ApplyAllFiles(path, ProcessFile, FolderProcessed);
}
static void ProcessFile(string path) {/* ... */}
static void FolderProcessed(string path) {/* ... */}
static void ApplyAllFiles(string folder, Action<string> fileAction, Action<string> folderProcessed)
{
foreach (string file in Directory.GetFiles(folder))
{
fileAction(file);
}
foreach (string subDir in Directory.GetDirectories(folder))
{
try
{
ApplyAllFiles(subDir, fileAction);
}
catch
{
// swallow, log, whatever
}
}
//**** New action invoked here:
folderProcessed(folder);
}
}