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


C# DirectoryInfo.Sort方法代码示例

本文整理汇总了C#中System.IO.DirectoryInfo.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.Sort方法的具体用法?C# DirectoryInfo.Sort怎么用?C# DirectoryInfo.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.DirectoryInfo的用法示例。


在下文中一共展示了DirectoryInfo.Sort方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Z

 public void Z()
 {
     var files = new DirectoryInfo(@"c:\proj\visionquest\src\sharpdx").GetFiles("*.cs", SearchOption.AllDirectories).ToList();
     files.Sort((x, y) => -x.LastWriteTime.CompareTo(y.LastWriteTime));
     for (var i = 0; i < 99; i++)
         System.Diagnostics.Debug.Print("{0:yyyy MMMM dd HH mm} {1}", files[i].LastWriteTime, files[i].FullName);
 }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:7,代码来源:Class1.cs

示例2: LoadMatches

        private void LoadMatches()
        {
            FileInfo summaryFile = new FileInfo(App.SummaryPath);
              var dir = new DirectoryInfo(App.Rootpath);
              if (!dir.Exists) dir.Create();

              Logger.WriteLine("Loading replays from {0}", App.Rootpath);

              FileStream loadSummary;
              if (!summaryFile.Exists) loadSummary = summaryFile.Create();
              else loadSummary = summaryFile.Open(FileMode.Open);
              var mems = new MemoryStream();
              loadSummary.CopyTo(mems);
              loadSummary.Close();

              dynamic summary;
              try {
            summary = MFroehlich.Parsing.MFro.MFroFormat.Deserialize(mems.ToArray());
            Logger.WriteLine("Loaded {0} summaries from {1}", summary.Count, summaryFile.FullName);
              } catch (Exception x) {
            summary = new JSONObject();
            Logger.WriteLine(Priority.Error, "Error loading summaries {0}, starting new summary list", x.Message);
              }
              dynamic newSummary = new JSONObject();

              List<FileInfo> files = new DirectoryInfo(App.Rootpath).EnumerateFiles("*.lol").ToList();
              files.Sort((a, b) => b.Name.CompareTo(a.Name));

              int summaries = 0;
              var timer = new System.Diagnostics.Stopwatch(); timer.Start();

              for (int i = 0; i < files.Count; i++) {
            string filename = files[i].Name.Substring(0, files[i].Name.Length - 4);

            ReplayItem item;
            if (summary.ContainsKey(filename)) {
              item = new ReplayItem((SummaryData) summary[filename], files[i]);
              newSummary.Add(filename, summary[filename]);
            } else {
              SummaryData data = new SummaryData(new MFroReplay(files[i]));
              newSummary.Add(filename, JSONObject.From(data));
              item = new ReplayItem(data, files[i]);
              summaries++;
            }
            item.MouseUp += OpenDetails;
            replays.Add(item);
              }

              Logger.WriteLine("All replays loaded, took {0}ms", timer.ElapsedMilliseconds);

              using (FileStream saveSummary = summaryFile.Open(FileMode.Open)) {
            byte[] summBytes = MFroehlich.Parsing.MFro.MFroFormat.Serialize(newSummary);
            saveSummary.Write(summBytes, 0, summBytes.Length);
            Logger.WriteLine("Saved summaries, {0} total summaries, {1} newly generated", newSummary.Count, summaries);
              }
              Search();
              ReplayArea.Visibility = System.Windows.Visibility.Visible;
              LoadArea.Visibility = System.Windows.Visibility.Hidden;
              Console.WriteLine("DONE");
        }
开发者ID:mfro,项目名称:LeagueReplay,代码行数:60,代码来源:MainWindow.xaml.cs

示例3: HardResetUpdatesTheContentOfTheWorkingDirectory

        public void HardResetUpdatesTheContentOfTheWorkingDirectory()
        {
            bool progressCalled = false;

            string path = SandboxStandardTestRepo();
            using (var repo = new Repository(path))
            {
                var names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();

                File.Delete(Path.Combine(repo.Info.WorkingDirectory, "README"));
                Touch(repo.Info.WorkingDirectory, "WillNotBeRemoved.txt", "content\n");

                Assert.True(names.Count > 4);

                var commit = repo.Lookup<Commit>("HEAD~3");
                repo.Reset(ResetMode.Hard, commit, new CheckoutOptions()
                {
                    OnCheckoutProgress = (_path, _completed, _total) => { progressCalled = true; },
                });

                names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();
                names.Sort(StringComparer.Ordinal);

                Assert.Equal(true, progressCalled);
                Assert.Equal(new[] { ".git", "README", "WillNotBeRemoved.txt", "branch_file.txt", "new.txt", "new_untracked_file.txt" }, names);
            }
        }
开发者ID:PKRoma,项目名称:libgit2sharp,代码行数:27,代码来源:ResetHeadFixture.cs

示例4: Validate

        public void Validate(string directoryPath)
        {
            var regex = new Regex(@"^(?<index>[0-9]+).+\.sql$");

            var indexes = new DirectoryInfo(directoryPath)
                .GetFiles()
                .Select(f =>
                {
                    var match = regex.Match(f.Name);

                    var index = match.Groups["index"].Value;

                    return int.Parse(index);
                })
                .ToList();
            
            if (indexes.Count < 2)
            {
                return;
            }

            indexes.Sort();
            
            for (var i = 0; i < indexes.Count - 1; i++)
            {
                var diff = indexes[i + 1] - indexes[i];

                if (diff != 1)
                {
                    throw new WrongOrderException("There is a gap between scripts. Files should be contiguous");
                }
            }            
        }
开发者ID:CHECK24,项目名称:c24.Sqlizer,代码行数:33,代码来源:FilesOrderValidationRule.cs

示例5: Init

        void Init()
        {
            if (!Directory.Exists(_info.DatePath)) {
                return;
            }

            var list = new DirectoryInfo(_info.DatePath).GetFiles().ToList();
            list.Sort((x, y) => String.Compare(x.Name, y.Name, StringComparison.Ordinal));

            foreach (var file in list) {
                var macth = Regex.Match(file.Name, @"\d{8}");
                if (macth.Success) {
                    DateTime date;
                    if (DateTime.TryParseExact(macth.Groups[0].Value, "yyyyMMdd", null, DateTimeStyles.None, out date)
                        && date >= _info.DateTime1
                        && date <= _info.DateTime2) {
                        _files.AddLast(file);
                        _count += (int)file.Length;
                    }
                }
            }

            if (_count > 0) {
                EndOfSeries = false;
                _progressDelta = (int)Math.Ceiling(((double)_count / 100));
                _progressCount = _progressDelta;
                _progressPercent = 0;
                OpenReader();
            }

            if (_current == null)
                EndOfSeries = true;
        }
开发者ID:kandsy,项目名称:QuantBox.DataSimulator,代码行数:33,代码来源:DataSeriesObject_bak.cs

示例6: HardResetUpdatesTheContentOfTheWorkingDirectory

        public void HardResetUpdatesTheContentOfTheWorkingDirectory()
        {
            string path = CloneStandardTestRepo();
            using (var repo = new Repository(path))
            {
                var names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();

                File.Delete(Path.Combine(repo.Info.WorkingDirectory, "README"));
                File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, "WillNotBeRemoved.txt"), "content\n");

                Assert.True(names.Count > 4);

                repo.Reset(ResetOptions.Hard, "HEAD~3");

                names = new DirectoryInfo(repo.Info.WorkingDirectory).GetFileSystemInfos().Select(fsi => fsi.Name).ToList();
                names.Sort(StringComparer.Ordinal);

                Assert.Equal(new[] { ".git", "README", "WillNotBeRemoved.txt", "branch_file.txt", "new.txt", "new_untracked_file.txt" }, names);
            }
        }
开发者ID:TiThompson,项目名称:libgit2sharp,代码行数:20,代码来源:ResetHeadFixture.cs


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