【问题标题】:Determine if there is folder on one of the subfolder in any level c#确定任何级别c#中的子文件夹之一上是否有文件夹
【发布时间】:2016-03-02 21:31:50
【问题描述】:

在 C# 上是否有任何有效的方法来确定文件夹的任何级别中是否存在名为 'sub' 的子文件夹。

意思是,给定路径,我想确定路径的子树上是否有包含文件夹“sub”的任何级别。

谢谢!

【问题讨论】:

    标签: c# find filesystems subdirectory


    【解决方案1】:

    您可以使用Directory.GetDirectories()Directory.EnumerateDirectories() 方法,指定在搜索操作中包括当前目录及其所有子目录:

    var subDirs =  Directory.GetDirectories("ROOT PATH", "sub", SearchOption.AllDirectories);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-09
      • 2015-11-27
      • 2021-02-16
      • 2011-05-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多