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


C# Pri.LongPath.DirectoryInfo.GetFiles方法代码示例

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


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

示例1: TestGetFilesWithSearchWithNoResults

 public void TestGetFilesWithSearchWithNoResults()
 {
     var di = new DirectoryInfo(uncDirectory);
     var files = di.GetFiles("giberish").ToArray();
     Assert.AreEqual(0, files.Length);
 }
开发者ID:KsWare,项目名称:LongPath,代码行数:6,代码来源:UncDirectoryInfoTests.cs

示例2: TestGetFiles

 public void TestGetFiles()
 {
     var di = new DirectoryInfo(uncDirectory);
     var files = di.GetFiles().ToArray();
     Assert.AreEqual(1, files.Length);
     Assert.IsTrue(files.Any(f => f.Name == Filename));
 }
开发者ID:KsWare,项目名称:LongPath,代码行数:7,代码来源:UncDirectoryInfoTests.cs

示例3: TestGetFilesWithSearch

 public void TestGetFilesWithSearch()
 {
     var di = new DirectoryInfo(uncDirectory);
     var files = di.GetFiles("*").ToArray();
     Assert.AreEqual(1, files.Length);
 }
开发者ID:KsWare,项目名称:LongPath,代码行数:6,代码来源:UncDirectoryInfoTests.cs

示例4: TestGetRecursiveFilesWithSubsetSearch

        public void TestGetRecursiveFilesWithSubsetSearch()
        {
            var tempLongPathFilename = Path.Combine(uncDirectory, Path.GetRandomFileName());
            Directory.CreateDirectory(tempLongPathFilename);
            try
            {
                Assert.IsTrue(Directory.Exists(tempLongPathFilename));
                string newEmptyFile1 = Util.CreateNewEmptyFile(tempLongPathFilename, "A-file");
                string newEmptyFile2 = Util.CreateNewEmptyFile(tempLongPathFilename, "B-file");
                try
                {
                    var randomFileName = Path.GetFileName(newEmptyFile1);

                    var di = new DirectoryInfo(uncDirectory);
                    var files = di.GetFiles("A*", SearchOption.AllDirectories).ToArray();
                    Assert.AreEqual(1, files.Length);
                    Assert.IsTrue(files.Any(f => f.Name == Path.GetFileName(newEmptyFile1) && f.DirectoryName == Path.GetDirectoryName(newEmptyFile1)));
                    Assert.IsFalse(files.Any(f => f.Name == Path.GetFileName(newEmptyFile2) && f.DirectoryName == Path.GetDirectoryName(newEmptyFile2)));
                    Assert.IsFalse(files.Any(f => f.Name == Path.GetFileName(Filename) && f.DirectoryName == Path.GetDirectoryName(Filename)));
                }
                finally
                {
                    File.Delete(newEmptyFile1);
                    File.Delete(newEmptyFile2);
                }
            }
            finally
            {
                const bool recursive = true;
                Directory.Delete(tempLongPathFilename, recursive);
            }
        }
开发者ID:KsWare,项目名称:LongPath,代码行数:32,代码来源:UncDirectoryInfoTests.cs

示例5: DatePicker_SelectedDateChanged

        private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            if (string.IsNullOrEmpty(_currentPath))
                return;

            DatePicker dp = sender as DatePicker;
            if (dp == null)
            {

                lblStatus.Text = "Error getting selected date.";
                return;
            }

            try
            {
                changes = new List<ChangedFile>();
                lstChanegs.Items.Clear();
                btnSave.IsEnabled = false;
                btnSave.Visibility = Visibility.Hidden;

                DirectoryInfo dInf = new DirectoryInfo(_currentPath);
                foreach (var fileInfo in dInf.GetFiles("*", System.IO.SearchOption.AllDirectories))
                {
                    if (fileInfo.CreationTimeUtc >= dp.SelectedDate || fileInfo.LastWriteTimeUtc >= dp.SelectedDate)
                    {
                        if (Globals.SelectedFilter.FilePassesFilter(fileInfo))
                        {
                            changes.Add(fileInfo);
                            lstChanegs.Items.Add(fileInfo);
                        }
                    }
                }

                lblStatus.Text = "Total Changes: " + changes.Count;

                if(changes.Count > 0)
                {
                    btnSave.IsEnabled = true;
                    btnSave.Visibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }
        }
开发者ID:sidsoft2014,项目名称:ChangeTracker,代码行数:46,代码来源:HistoricChangesWindow.xaml.cs

示例6: TestGetRecursiveFilesWithAllSearch

        public void TestGetRecursiveFilesWithAllSearch()
        {
            var tempLongPathFilename = Path.Combine(longPathDirectory, Path.GetRandomFileName());
            Directory.CreateDirectory(tempLongPathFilename);
            try
            {
                Assert.IsTrue(Directory.Exists(tempLongPathFilename));
                string newEmptyFile = Util.CreateNewEmptyFile(tempLongPathFilename);
                try
                {
                    var randomFileName = Path.GetFileName(newEmptyFile);

                    var di = new DirectoryInfo(longPathDirectory);
                    var files = di.GetFiles("*", SearchOption.AllDirectories).ToArray();
                    Assert.AreEqual(2, files.Length);
                    Assert.IsTrue(files.Any(f => f.Name == Filename));
                    Assert.IsTrue(files.Any(f => f.Name == randomFileName));

                }
                finally
                {
                    File.Delete(newEmptyFile);
                }
            }
            finally
            {
                const bool recursive = true;
                Directory.Delete(tempLongPathFilename, recursive);
            }
        }
开发者ID:KsWare,项目名称:LongPath,代码行数:30,代码来源:DirectoryInfoTests.cs

示例7: ScanParallel

        private void ScanParallel(FilterCollection sc, DirectoryInfo dInf)
        {
            // Check all files within the directory and subdirectories.
            Parallel.ForEach(dInf.GetFiles("*", SearchOption.AllDirectories), (file) =>
            {
                // Check if we want to skip the directory based on the current mode and list of user excluded directories.
                if (!_vm.ExcludedDirectorys.Contains(file.DirectoryName)
                && !sc.FilteredDirectories.Contains(file.DirectoryName.Split('\\').Last().ToLower()))
                {
                    // If file was written to or created after start time and is not already in list of changes.
                    if ((file.LastWriteTimeUtc > _timeStarted || file.CreationTimeUtc > _timeStarted)
                     && !sc.FilteredExtensions.Contains(file.Extension.ToLower()))
                    {
                        bool exclude = false;

                        // Check if filename includes excluded strings.
                        foreach (var exculded in sc.FilteredStrings)
                        {
                            // Convert both comparion strings to lower in order to prevent false negatives.
                            if (file.FullName.ToLower().Contains(exculded.ToLower()))
                            {
                                // Can't use continue or break to skip file here as this is in a sub-loop.
                                exclude = true;
                                break;
                            }
                        }

                        if (!exclude)
                            _vm.AddNewChange(file);
                    }
                }
            });
        }
开发者ID:sidsoft2014,项目名称:ChangeTracker,代码行数:33,代码来源:Watcher.cs

示例8: Scan

        private void Scan(FilterCollection sc, DirectoryInfo dInf)
        {
            // Check all files within the directory and subdirectories.
            foreach (var file in dInf.GetFiles("*", SearchOption.AllDirectories))
            {
                // Check if we want to skip the directory based on the current mode and list of user excluded directories.
                if (_vm.ExcludedDirectorys.Contains(file.DirectoryName) || sc.FilteredDirectories.Contains(file.DirectoryName.Split('\\').Last().ToLower()))
                    continue;

                // Incase we are trying to check a temporary file that may have now been deleted.
                if (file.Exists)
                {
                    try
                    {
                        // If file was written to or created after start time and is not already in list of changes.
                        if ((file.LastWriteTimeUtc > _timeStarted || file.CreationTimeUtc > _timeStarted))
                        {
                            if (sc.FilePassesFilter(file))
                                _vm.AddNewChange(file);
                        }
                    }
                    // Catch any instances where file has been deleted during checking.
                    catch (NullReferenceException)
                    {

                    }
                }
            }
        }
开发者ID:sidsoft2014,项目名称:ChangeTracker,代码行数:29,代码来源:Watcher.cs


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