我有一个功能,目前抓住所有文件夹和子文件夹,检查ACL是否正在建立一个小工具,但我正在试图找出如何限制它可以达到的深度.例如,你有一个4级深度的文件夹,但我希望只能为ACL获取3级.
目前我有它编码:
private void StepThroughDirectories(string dir)
{
string[] directories = Directory.GetDirectories(dir);
try
{
foreach (string d in Directory.GetDirectories(dir))
{
if (recCount < (int)Depth)
{
GetACLs(d, new DirectoryInfo(d));
pBar.Value += 1;
//MessageBox.Show("Recursive Level: " + counter.ToString());
recCount++;
StepThroughDirectories(d);
}
else
{
recCount--;
}
}
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
显然这并不像以前那么好,因为我已经解决了一段时间的问题,但如果有人能指出我正确的方向来解决这个问题,我会非常高兴!