本文整理汇总了C#中System.IO.FileInfo.GetDirectories方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.GetDirectories方法的具体用法?C# FileInfo.GetDirectories怎么用?C# FileInfo.GetDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.GetDirectories方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args) {
if (args.Length == 0) {
Console.WriteLine("Find 'Code2Xml.Core' directory due to no arguments.");
var dir = new FileInfo(Assembly.GetEntryAssembly().Location).Directory;
while (true) {
var dirs = dir.GetDirectories("Code2Xml.Core", SearchOption.AllDirectories);
if (dirs.Length > 0) {
args = new[] { dirs[0].FullName };
break;
}
dir = dir.Parent;
if (dir == null) {
Console.WriteLine("Can't find 'Code2Xml.Core' directory.");
args = new[] { Console.In.ReadLine() };
break;
}
}
}
foreach (var arg in args) {
var path = Path.GetFullPath(arg);
var dir = Directory.Exists(path) ? path : Path.GetDirectoryName(path);
var grammarFiles = Directory.GetFiles(dir, "*.g", SearchOption.AllDirectories);
foreach (var grammarFile in grammarFiles) {
Console.WriteLine(grammarFile);
var info = new ProcessStartInfo {
FileName = "Antlr3",
Arguments = '"' + grammarFile + '"',
CreateNoWindow = true,
UseShellExecute = true,
WorkingDirectory = Path.GetDirectoryName(grammarFile)
};
using (var p = Process.Start(info)) {
p.WaitForExit();
}
var csFiles = Directory.GetFiles(
info.WorkingDirectory, "*.cs", SearchOption.TopDirectoryOnly);
foreach (var file in csFiles) {
if (file.EndsWith("Parser.cs")) {
Console.WriteLine(file);
ParserModifier.Modify(file);
} else if (file.EndsWith("Lexer.cs")) {
Console.WriteLine(file);
LexerModifier.Modify(file);
}
}
}
var grammar4Files = Directory.GetFiles(dir, "*.g4", SearchOption.AllDirectories);
foreach (var grammarFile in grammar4Files) {
Console.WriteLine(grammarFile);
Antlr4ParserModifier.Modify(grammarFile);
}
}
}
示例2: RunBundler
private void RunBundler(ProjectItem projectItem)
{
if (projectItem == null) return;
try
{
if (projectItem.ContainingProject == null) return;
// make sure this is a valid bundle file type
if (!IsAllowedExtension(projectItem.Name)) return;
// make sure the bundler exists
var directory = new FileInfo(projectItem.ContainingProject.FileName).Directory;
var bunderDirectory = directory.GetDirectories("bundler").FirstOrDefault();
if (bunderDirectory == null) return;
var bundleCommand = bunderDirectory.GetFiles("bundler.cmd").FirstOrDefault();
if (bundleCommand == null) return;
// make sure the files are in the bundler folder
var fileNames = new List<string>();
for (short i = 0; i < projectItem.FileCount; i += 1)
fileNames.Add(projectItem.FileNames[i]);
if (fileNames.Any(m => m.StartsWith(bunderDirectory.FullName))) return;
RunBundler(bundleCommand.FullName);
}
catch (Exception e)
{
// project item probably doesn't have a document
Debug.WriteLine(e.Message);
}
}
示例3: Init
private void Init()
{
var targetPath = Path.Combine(_pluginPath, _packageName + "." + _packageVersion);
var plugDir = new FileInfo(targetPath).Directory;
var catalogs = plugDir.GetDirectories("*", SearchOption.AllDirectories).Select(x => new DirectoryCatalog(x.FullName));
var directoryAggregate = new AggregateCatalog(catalogs);
_container = new CompositionContainer(directoryAggregate);
_container.ComposeParts(this);
_node = _exports.First();
}
示例4: SetToV2Beta1
public static void SetToV2Beta1(string/*!*/ platformAssembliesLocation)
{
TargetPlatform.TargetVersion = new Version(2, 0, 3600);
TargetPlatform.GenericTypeNamesMangleChar = '!';
string dotNetDirLocation = null;
if (platformAssembliesLocation == null || platformAssembliesLocation.Length == 0)
{
DirectoryInfo dotNetDir = new FileInfo(new Uri(typeof(object).Module.Assembly.Location).LocalPath).Directory.Parent;
dotNetDirLocation = dotNetDir.FullName;
if (dotNetDirLocation != null) dotNetDirLocation = dotNetDirLocation.ToUpper(System.Globalization.CultureInfo.InvariantCulture);
DateTime creationTime = DateTime.MinValue;
foreach (DirectoryInfo subdir in dotNetDir.GetDirectories("v2.0*"))
{
if (subdir == null) continue;
if (subdir.CreationTime < creationTime) continue;
FileInfo[] mscorlibs = subdir.GetFiles("mscorlib.dll");
if (mscorlibs != null && mscorlibs.Length == 1)
{
platformAssembliesLocation = subdir.FullName;
creationTime = subdir.CreationTime;
}
}
}
else
TargetPlatform.PlatformAssembliesLocation = platformAssembliesLocation;
if (dotNetDirLocation != null && (platformAssembliesLocation == null || platformAssembliesLocation.Length == 0))
{
int pos = dotNetDirLocation.IndexOf("FRAMEWORK");
if (pos > 0 && dotNetDirLocation.IndexOf("FRAMEWORK64") < 0)
{
dotNetDirLocation = dotNetDirLocation.Replace("FRAMEWORK", "FRAMEWORK64");
if (Directory.Exists(dotNetDirLocation))
{
DirectoryInfo dotNetDir = new DirectoryInfo(dotNetDirLocation);
DateTime creationTime = DateTime.MinValue;
foreach (DirectoryInfo subdir in dotNetDir.GetDirectories("v2.0*"))
{
if (subdir == null) continue;
if (subdir.CreationTime < creationTime) continue;
FileInfo[] mscorlibs = subdir.GetFiles("mscorlib.dll");
if (mscorlibs != null && mscorlibs.Length == 1)
{
platformAssembliesLocation = subdir.FullName;
creationTime = subdir.CreationTime;
}
}
}
}
}
TargetPlatform.PlatformAssembliesLocation = platformAssembliesLocation;
TargetPlatform.InitializeStandardAssemblyLocationsWithDefaultValues(platformAssembliesLocation);
TrivialHashtable assemblyReferenceFor = new TrivialHashtable(46);
for (int i = 0, n = TargetPlatform.FxAssemblyNames.Length; i < n; i++)
{
string name = TargetPlatform.FxAssemblyNames[i];
string version = TargetPlatform.FxAssemblyVersion2Build3600[i];
string token = TargetPlatform.FxAssemblyToken[i];
AssemblyReference aref = new AssemblyReference(name + ", Version=" + version + ", Culture=neutral, PublicKeyToken=" + token);
aref.Location = platformAssembliesLocation + "\\" + name + ".dll";
//^ assume name != null;
assemblyReferenceFor[Identifier.For(name).UniqueIdKey] = aref;
}
TargetPlatform.assemblyReferenceFor = assemblyReferenceFor;
}
示例5: Init
private void Init()
{
// Use RegistrationBuilder to set up our MEF parts.
//var targetPath = Path.Combine(this.pluginPath, packageName + "." + packageVersion);
var targetPath = _pluginPath;
var plugDir = new FileInfo(targetPath).Directory;
var catalogs = plugDir.GetDirectories("*", SearchOption.AllDirectories).Select(x => new DirectoryCatalog(x.FullName));
var directoryAggregate = new AggregateCatalog(catalogs);
_container = new CompositionContainer(directoryAggregate);
_container.ComposeParts(this);
}