本文整理汇总了C#中IDirectory.FileExists方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.FileExists方法的具体用法?C# IDirectory.FileExists怎么用?C# IDirectory.FileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectory
的用法示例。
在下文中一共展示了IDirectory.FileExists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadConfiguration
/// <summary>
/// Loads configuration for the specified directory and its subdirectories and file using the specified configuration node as parent node
/// </summary>
internal void LoadConfiguration(IConfigurationNode parentNode, IDirectory directory)
{
m_Logger.Info($"Loading configuration for directory '{directory.FullPath}'");
// determine configuration node for directory
IConfigurationNode configNode;
// config file present in directory => create new node
if (directory.FileExists(s_DirectoryConfigName))
{
configNode = new HierarchicalConfigurationNode(parentNode, LoadConfigurationFile(directory.GetFile(s_DirectoryConfigName)));
}
// no config file found => use parent node
else
{
configNode = parentNode;
}
m_Mapper.AddMapping(configNode, directory);
// load configuration for files in the directory
foreach (var file in directory.Files)
{
LoadConfiguration(configNode, file);
}
// load configuration for subdirectories
foreach (var dir in directory.Directories)
{
LoadConfiguration(configNode, dir);
}
}
示例2: DirectoryEqual
public static void DirectoryEqual(IDirectory expected, IDirectory actual)
{
Assert.Equal(expected.Path, actual.Path);
Assert.Equal(expected.Name, actual.Name);
Assert.Equal(expected.Directories.Count(), actual.Directories.Count());
Assert.Equal(expected.Files.Count(), actual.Files.Count());
foreach (var directory in expected.Directories)
{
Assert.True(actual.DirectoryExists(directory.Name));
DirectoryEqual(directory, actual.GetDirectory(directory.Name));
}
foreach (var file in expected.Files)
{
Assert.True(actual.FileExists(file.Name));
FileEqual(file, actual.GetFile(file.Name));
}
}