本文整理汇总了C#中System.IO.Abstractions.DirectoryInfoBase.GetDirectories方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfoBase.GetDirectories方法的具体用法?C# DirectoryInfoBase.GetDirectories怎么用?C# DirectoryInfoBase.GetDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Abstractions.DirectoryInfoBase
的用法示例。
在下文中一共展示了DirectoryInfoBase.GetDirectories方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDirectories
internal static IDictionary<string, DirectoryInfoBase> GetDirectories(DirectoryInfoBase info)
{
if (info == null)
{
return null;
}
return info.GetDirectories().ToDictionary(d => d.Name, StringComparer.OrdinalIgnoreCase);
}
示例2: CollectDirectories
private bool CollectDirectories(DirectoryInfoBase directory, INode rootNode, GeneralTree<INode> tree)
{
List<GeneralTree<INode>> collectedNodes = new List<GeneralTree<INode>>();
foreach (DirectoryInfoBase subDirectory in directory.GetDirectories().OrderBy(di => di.Name))
{
GeneralTree<INode> subTree = this.Crawl(subDirectory, rootNode);
if (subTree != null)
{
collectedNodes.Add(subTree);
}
}
foreach (var node in collectedNodes)
{
tree.Add(node);
}
return collectedNodes.Count > 0;
}
示例3: Copy
internal static void Copy(string sourcePath,
string destinationPath,
DirectoryInfoBase sourceDirectory,
DirectoryInfoBase destinationDirectory,
Func<string, DirectoryInfoBase> createDirectoryInfo,
bool skipScmFolder)
{
// Skip hidden directories and directories that begin with .
if (skipScmFolder && IsSourceControlFolder(sourceDirectory))
{
return;
}
if (!destinationDirectory.Exists)
{
destinationDirectory.Create();
}
foreach (var sourceFile in sourceDirectory.GetFiles())
{
string path = GetDestinationPath(sourcePath, destinationPath, sourceFile);
sourceFile.CopyTo(path, overwrite: true);
}
var destDirectoryLookup = GetDirectories(destinationDirectory);
foreach (var sourceSubDirectory in sourceDirectory.GetDirectories())
{
DirectoryInfoBase targetSubDirectory;
if (!destDirectoryLookup.TryGetValue(sourceSubDirectory.Name, out targetSubDirectory))
{
string path = GetDestinationPath(sourcePath, destinationPath, sourceSubDirectory);
targetSubDirectory = createDirectoryInfo(path);
}
Copy(sourcePath, destinationPath, sourceSubDirectory, targetSubDirectory, createDirectoryInfo, skipScmFolder);
}
}