本文整理汇总了C#中System.IO.Abstractions.DirectoryInfoBase.GetFiles方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfoBase.GetFiles方法的具体用法?C# DirectoryInfoBase.GetFiles怎么用?C# DirectoryInfoBase.GetFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Abstractions.DirectoryInfoBase
的用法示例。
在下文中一共展示了DirectoryInfoBase.GetFiles方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryReadNpmVersion
private static string TryReadNpmVersion(DirectoryInfoBase nodeDir)
{
var npmRedirectionFile = nodeDir.GetFiles("npm.txt").FirstOrDefault();
if (npmRedirectionFile == null)
{
return null;
}
using (StreamReader reader = new StreamReader(npmRedirectionFile.OpenRead()))
{
return reader.ReadLine();
}
}
示例2: 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);
}
}
示例3: GetFiles
internal static IDictionary<string, FileInfoBase> GetFiles(DirectoryInfoBase info)
{
if (info == null)
{
return null;
}
return info.GetFiles().ToDictionary(f => f.Name, StringComparer.OrdinalIgnoreCase);
}
示例4: CollectFiles
private bool CollectFiles(DirectoryInfoBase directory, INode rootNode, GeneralTree<INode> tree)
{
List<INode> collectedNodes = new List<INode>();
foreach (FileInfoBase file in directory.GetFiles().Where(file => this.relevantFileDetector.IsRelevant(file)))
{
INode node = null;
try
{
node = this.featureNodeFactory.Create(rootNode.OriginalLocation, file);
}
catch (Exception)
{
if (Log.IsWarnEnabled)
{
// retrieving the name as file.FullName may trigger an exception if the FullName is too long
// so we retreive Name and DirectoryName separately
// https://github.com/picklesdoc/pickles/issues/199
var fullName = file.Name + " in directory " + file.DirectoryName;
Log.Warn("The file {0} will be ignored because it could not be read in properly", fullName);
}
}
if (node != null)
{
collectedNodes.Add(node);
}
}
foreach (var node in OrderFileNodes(collectedNodes))
{
tree.Add(node);
}
return collectedNodes.Count > 0;
}
示例5: tryResolveAssembly
Assembly tryResolveAssembly(DirectoryInfoBase directory, ResolveEventArgs args)
{
try {
if (directory.Exists) {
var files = directory.GetFiles("*.dll")
.Concat(directory.GetFiles("*.exe"));
foreach (var f in files) {
var assemblyName = AssemblyName.GetAssemblyName(f.FullName);
if (assemblyName.FullName == args.Name) {
return Assembly.Load(assemblyName);
}
}
}
}
catch (Exception ex) {
log.WarnException("Could not resolve assembly: " + args.Name, ex);
}
return null;
}
示例6: CollectFiles
private bool CollectFiles(DirectoryInfoBase directory, INode rootNode, GeneralTree<INode> tree)
{
List<INode> collectedNodes = new List<INode>();
foreach (FileInfoBase file in directory.GetFiles().Where(file => this.relevantFileDetector.IsRelevant(file)))
{
INode node = null;
try
{
node = this.featureNodeFactory.Create(rootNode.OriginalLocation, file);
}
catch (Exception)
{
if (log.IsWarnEnabled)
{
log.WarnFormat("The file, {0}, will be ignored because it could not be read in properly", file.FullName);
}
}
if (node != null)
{
collectedNodes.Add(node);
}
}
foreach (var node in OrderFileNodes(collectedNodes))
{
tree.Add(node);
}
return collectedNodes.Count > 0;
}
示例7: CollectFiles
private bool CollectFiles(DirectoryInfoBase directory, INode rootNode, Tree tree)
{
List<INode> collectedNodes = new List<INode>();
foreach (FileInfoBase file in directory.GetFiles().Where(file => this.relevantFileDetector.IsRelevant(file)))
{
INode node = this.featureNodeFactory.Create(rootNode.OriginalLocation, file);
collectedNodes.Add(node);
}
foreach (var node in OrderFileNodes(collectedNodes))
{
tree.Add(node);
}
return collectedNodes.Count > 0;
}