当前位置: 首页>>代码示例>>C#>>正文


C# DirectoryInfo.SelectMany方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Raven11,项目名称:Crypsis_One,代码行数:19,代码来源:DomainServices.cs

示例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();
        }
开发者ID:mihasic,项目名称:MyPlayground,代码行数:22,代码来源:PreApplicationInit.cs

示例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;
        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:30,代码来源:FileStatus.cs


注:本文中的System.IO.DirectoryInfo.SelectMany方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。