本文整理汇总了C#中System.IO.DirectoryInfo.SelectMany方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.SelectMany方法的具体用法?C# DirectoryInfo.SelectMany怎么用?C# DirectoryInfo.SelectMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了DirectoryInfo.SelectMany方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LearnFromFiles
public void LearnFromFiles( string directoryPath )
{
IEnumerable< string > allLines = null;
try
{
var files = new DirectoryInfo( directoryPath ).EnumerateFiles( "*.txt" );
allLines = files.SelectMany( x => File.ReadLines( x.FullName ) );
}
catch ( Exception e )
{
File.AppendAllText( "C:/ErrorLog.log" ,e.Message +"\nIt Occured On " +DateTime.Now);
return;
}
foreach ( var line in allLines )
{
this.LearnFromSentence(line);
}
}
示例2: Initialize
public static void Initialize()
{
var pluginContainers = new DirectoryInfo(HostingEnvironment.MapPath("~/Plugins"))
.GetFiles("*.dll", SearchOption.TopDirectoryOnly)
.Select(f => new
{
//Assembly = AppDomain.CurrentDomain.Load(File.ReadAllBytes(f.FullName)),
Assembly = Assembly.Load(AssemblyName.GetAssemblyName(f.FullName)),
Name = f.Name
}).ToList();
pluginContainers.ForEach(pc => BuildManager.AddReferencedAssembly(pc.Assembly));
pluginContainers.ForEach(pc => Register(pc.Name, pc.Assembly));
HostingEnvironment.RegisterVirtualPathProvider(new AssemblyResourceProvider());
pluginContainers.SelectMany(pc => pc.Assembly.GetTypes())
.Where(t => "Bootstrapper".Equals(t.Name, StringComparison.OrdinalIgnoreCase))
.Select(t => t.GetMethod("Init", BindingFlags.Static | BindingFlags.Public))
.Where(mi => mi != null && !mi.GetParameters().Any() && !mi.IsGenericMethodDefinition)
.Select(mi => mi.Invoke(null, null))
.ToList();
}
示例3: MoveFilePacketCheckState
private IList<Track> MoveFilePacketCheckState(IInternalMusicSession msi, int packect, string iDirectoryIn, string iDirectoryOut, bool FindOriginalFiles)
{
//packect
var HalfFiles = new DirectoryInfo(iDirectoryIn).GetFiles().Where(fi => fi.Extension == FileServices.MP3).Take(packect).ToList();
Assert.That(HalfFiles.Count, Is.EqualTo(packect));
//string myout = this.TempDirectoryOut;
//MusicSessionImpl msi = ms as MusicSessionImpl;
IList<Track> res = null;
if (FindOriginalFiles)
{
var InitialTrack = HalfFiles.SelectMany(fi => msi.Tracks.Find(new FakeTrackDescriptor(fi.FullName))).ToList();
Assert.That(InitialTrack.Count, Is.EqualTo(packect));
Assert.That(InitialTrack.All(mt => mt.Precision == MatchPrecision.Exact), Is.True);
res = InitialTrack.Select(mt => mt.FindItem).ToList();
Assert.That(res.Count, Is.EqualTo(packect));
Assert.That(res.Cast<IInternalTrack>().All(tr => tr.InternalState == ObjectState.Available), Is.True);
}
HalfFiles.Apply(fi => fi.MoveTo(Path.Combine(iDirectoryOut, fi.Name)));
return res;
}