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


C# IFileSystem.GetFiles方法代码示例

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


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

示例1: FindDifferences

        public static IndexDifferences FindDifferences(
            IFileSystem fileSystem,
            IEnumerable<LucenePackage> indexedPackages,
            CancellationToken cancellationToken,
            Action<SynchronizationState> setState,
            SynchronizationMode mode)
        {
            setState(SynchronizationState.ScanningFiles);

            var fileSystemPackages = fileSystem.GetFiles(string.Empty, "*" + Constants.PackageExtension, true)
                                               .WithCancellation(cancellationToken)
                                               .Where(file => !fileSystem.IsTempFile(file))
                                               .ToArray();

            setState(SynchronizationState.ScanningIndex);

            var indexedPackagesByPath = indexedPackages
                                            .WithCancellation(cancellationToken)
                                            .ToDictionary(pkg => pkg.Path, StringComparer.InvariantCultureIgnoreCase);

            setState(SynchronizationState.Comparing);

            var calc = new IndexDifferenceCalculator(fileSystem, fileSystemPackages, indexedPackagesByPath);

            return calc.Calculate(mode);
        }
开发者ID:battenworks,项目名称:NuGet.Lucene,代码行数:26,代码来源:IndexDifferenceCalculator.cs

示例2: DirectorySync

 public DirectorySync(string directoryPath, ISyncFactory factory, IFileSystem fileSystem,
     IDirectoryValidator validator, IProjectFactory projectFactory)
 {
     var files = fileSystem.GetFiles(directoryPath, "*.csproj", SearchOption.AllDirectories);
     foreach (var file in files)
     {
         if (validator.IsDirectoryValid(file) && projectFactory.IsValidProject(file))
         {
             var project = factory.CreateProjectSynchronizer(file);
             _projects.Add(project);
         }
     }
 }
开发者ID:stormleoxia,项目名称:lx,代码行数:13,代码来源:DirectorySync.cs

示例3: RepositoryGroupManager

 /// <summary>
 /// Initializes a new instance of the <see cref="RepositoryGroupManager"/> class.  Provides nested operations over RepositoryManager instances.
 /// </summary>
 /// <param name="repository">The repository.</param>
 /// <param name="fileSystem"> </param>
 /// <example>Can be a direct path to a repository.config file</example>
 ///   
 /// <example>Can be a path to a directory, which will recursively locate all contained repository.config files</example>
 public RepositoryGroupManager(string repository, IFileSystem fileSystem)
 {
     Contract.Requires(fileSystem != null);
     this.fileSystem = fileSystem;
     
     if (fileSystem.DirectoryExists(repository))
     {
         // we're dealing with a directory
         //TODO Does this by default do a recursive???
         RepositoryManagers = new ConcurrentBag<RepositoryManager>(fileSystem.GetFiles(repository, "repositories.config", SearchOption.AllDirectories).Select(file => new RepositoryManager(file, new RepositoryEnumerator(fileSystem), fileSystem)).ToList());
     }
     else if (fileSystem.FileExists(repository) && Path.GetFileName(repository) == "repositories.config")
         RepositoryManagers = new ConcurrentBag<RepositoryManager>(new List<RepositoryManager> { new RepositoryManager(repository, new RepositoryEnumerator(fileSystem), fileSystem) });
     else
         throw new ArgumentOutOfRangeException("repository");
 }
开发者ID:modulexcite,项目名称:NuGet.Extensions,代码行数:24,代码来源:RepositoryGroupManager.cs

示例4: Compile

        private static async Task<CompilationResult> Compile(IFileSystem fileSystem)
        {
            var compiler = new CSharpCompiler(
                fileSystem.GetFiles("GeneratedCode", "*.cs", SearchOption.AllDirectories)
                    .Select(each => new KeyValuePair<string, string>(each, fileSystem.ReadFileAsText(each))).ToArray(),
                ManagedAssets.FrameworkAssemblies.Concat(
                    AppDomain.CurrentDomain.GetAssemblies()
                        .Where(each => !each.IsDynamic && !string.IsNullOrEmpty(each.Location))
                        .Select(each => each.Location)
                        .Concat(new[]
                        {
                            Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                "Microsoft.Rest.ClientRuntime.dll"),
                            Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                "Microsoft.Rest.ClientRuntime.Azure.dll")
                        })
                ));

            return await compiler.Compile(Microsoft.Rest.CSharp.Compiler.Compilation.OutputKind.DynamicallyLinkedLibrary);
        }
开发者ID:devigned,项目名称:autorest,代码行数:20,代码来源:CSharpCompilerHelper.cs

示例5: GetLastTranscodingFile

        private static FileSystemMetadata GetLastTranscodingFile(string playlist, string segmentExtension, IFileSystem fileSystem)
        {
            var folder = Path.GetDirectoryName(playlist);

            var filePrefix = Path.GetFileNameWithoutExtension(playlist) ?? string.Empty;

            try
            {
                return fileSystem.GetFiles(folder)
                    .Where(i => string.Equals(i.Extension, segmentExtension, StringComparison.OrdinalIgnoreCase) && Path.GetFileNameWithoutExtension(i.Name).StartsWith(filePrefix, StringComparison.OrdinalIgnoreCase))
                    .OrderByDescending(fileSystem.GetLastWriteTimeUtc)
                    .FirstOrDefault();
            }
            catch (DirectoryNotFoundException)
            {
                return null;
            }
        }
开发者ID:RavenB,项目名称:Emby,代码行数:18,代码来源:DynamicHlsService.cs

示例6: LoadMachineWideSettings

        /// <summary>
        /// Loads the machine wide settings.
        /// </summary>
        /// <remarks>
        /// For example, if <paramref name="paths"/> is {"IDE", "Version", "SKU" }, then
        /// the files loaded are (in the order that they are loaded):
        ///     %programdata%\NuGet\Config\IDE\Version\SKU\*.config
        ///     %programdata%\NuGet\Config\IDE\Version\*.config
        ///     %programdata%\NuGet\Config\IDE\*.config
        ///     %programdata%\NuGet\Config\*.config
        /// </remarks>
        /// <param name="fileSystem">The file system in which the settings files are read.</param>
        /// <param name="paths">The additional paths under which to look for settings files.</param>
        /// <returns>The list of settings read.</returns>
        public static IEnumerable<Settings> LoadMachineWideSettings(
            IFileSystem fileSystem,
            params string[] paths)
        {
            List<Settings> settingFiles = new List<Settings>();
            string basePath = @"NuGet\Config";
            string combinedPath = Path.Combine(paths);

            while (true)
            {
                string directory = Path.Combine(basePath, combinedPath);

                // load setting files in directory
                foreach (var file in fileSystem.GetFiles(directory, "*.config", recursive: false))
                {
                    var settings = ReadSettings(fileSystem, file, true);
                    if (settings != null)
                    {
                        settingFiles.Add(settings);
                    }
                }

                if (combinedPath.Length == 0)
                {
                    break;
                }

                int index = combinedPath.LastIndexOf(Path.DirectorySeparatorChar);
                if (index < 0)
                {
                    index = 0;
                }
                combinedPath = combinedPath.Substring(0, index);
            }

            return settingFiles;
        }
开发者ID:elanwu123,项目名称:dnx,代码行数:51,代码来源:Settings.cs

示例7: CopyNativeBinaries

        private void CopyNativeBinaries(IProjectSystem projectSystem, IFileSystem packagesFileSystem, PackageName packageName)
        {
            const string nativeBinariesFolder = "NativeBinaries";

            string nativeBinariesPath = Path.Combine(packageName.Name, nativeBinariesFolder);
            if (packagesFileSystem.DirectoryExists(nativeBinariesPath))
            {
                IEnumerable<string> nativeFiles = packagesFileSystem.GetFiles(nativeBinariesPath, "*.*", recursive: true);
                foreach (string file in nativeFiles)
                {
                    string targetPath = Path.Combine(Constants.BinDirectory, file.Substring(nativeBinariesPath.Length + 1));  // skip over NativeBinaries/ word
                    using (Stream stream = packagesFileSystem.OpenFile(file)) 
                    {
                        projectSystem.AddFile(targetPath, stream);
                    }
                }
            }
        }
开发者ID:themotleyfool,项目名称:NuGet,代码行数:18,代码来源:VsWebsiteHandler.cs

示例8: SearchFilesWithinOneSubFolders

 private IEnumerable<string> SearchFilesWithinOneSubFolders(IFileSystem fileSystem, string folder, string extension)
 {
     // get files directly under 'folder' or files under subfolders of 'folder'
     return fileSystem.GetFiles(folder, extension)
                      .Concat(fileSystem.GetDirectories(folder).SelectMany(subFolder => fileSystem.GetFiles(subFolder, extension)));
 }
开发者ID:themotleyfool,项目名称:NuGet,代码行数:6,代码来源:VsWebsiteHandler.cs

示例9: Compile

        protected async Task<CompilationResult> Compile(IFileSystem fileSystem)
        {
            var compiler = new CSharpCompiler(
                fileSystem.GetFiles("GeneratedCode", "*.cs", SearchOption.AllDirectories)
                    .Select(each => new KeyValuePair<string, string>(each, fileSystem.ReadFileAsText(each))).ToArray(),
                ManagedAssets.FrameworkAssemblies.Concat(
                    AppDomain.CurrentDomain.GetAssemblies()
                        .Where(each => !each.IsDynamic && !string.IsNullOrEmpty(each.Location) )
                        .Select(each => each.Location)
                        .Concat(new[]
                        {
                            Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                "Microsoft.Rest.ClientRuntime.dll"),
                            Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                "Microsoft.Rest.ClientRuntime.Azure.dll")
                        })
                    ));
            var result = await compiler.Compile(OutputKind.DynamicallyLinkedLibrary);
            
            // if it failed compiling and we're in an interactive session
            if (!result.Succeeded && System.Environment.OSVersion.Platform == PlatformID.Win32NT && System.Environment.UserInteractive)
            {
                var error = result.Messages.FirstOrDefault(each => each.Severity == DiagnosticSeverity.Error);
                if (error != null)
                {
                    // use this to dump the files to disk for examination
                    // open in Favorite Code Editor
                    InspectWithFavoriteCodeEditor(fileSystem.SaveFilesToTemp(GetType().Name), error.Location.GetMappedLineSpan());
                }
            }

            return result;
        }
开发者ID:devigned,项目名称:autorest,代码行数:33,代码来源:BugTest.cs

示例10: GetLastTranscodingFiles

        private static List<FileSystemMetadata> GetLastTranscodingFiles(string playlist, string segmentExtension, IFileSystem fileSystem, int count)
        {
            var folder = Path.GetDirectoryName(playlist);

            try
            {
				return fileSystem.GetFiles(folder)
                    .Where(i => string.Equals(i.Extension, segmentExtension, StringComparison.OrdinalIgnoreCase))
                    .OrderByDescending(fileSystem.GetLastWriteTimeUtc)
                    .Take(count)
                    .ToList();
            }
            catch (DirectoryNotFoundException)
            {
                return new List<FileSystemMetadata>();
            }
        }
开发者ID:ratanparai,项目名称:Emby,代码行数:17,代码来源:MpegDashService.cs

示例11: FromFile

        public static Project FromFile(string input, IFileSystem fileSystem)
        {
            var jObject = JsonConvert.DeserializeObject<Dictionary<string, JToken>>(input);
            var project = new Project();

            foreach (var entry in jObject)
            {
                var kindObj = entry.Key;
                string[] list;
                if (entry.Value is JArray)
                    list = entry.Value.ToObject<string[]>();
                else
                    list = new[] {entry.Value.ToObject<string>()};

                foreach (var item in list)
                {
                    var info = fileSystem.GetFileInfo(PathInfo.Create(item));
                    if (info == null)
                    {
                        var globPattern = GlobPattern.Create(item);
                        if (!globPattern.IsWildcard)
                            throw new InvalidProjectFileException($"Could not find file {item}.");

                        var items = fileSystem.GetFiles(globPattern);
                        foreach (var file in items)
                        {
                            var fileItem = new FileProjectItem(kindObj, file, fileSystem);
                            ProjectItem existing;
                            if (!project.TryGetItemById(fileItem.Identifier, out existing))
                                project.AddItem(fileItem);
                        }

                        project.AddSubscription(fileSystem.Subscribe(globPattern, a =>
                        {
                            HandleChange(a, project, kindObj, fileSystem);
                        }));
                    }
                    else
                    {
                        AddFile(fileSystem, project, kindObj, info, item);
                    }
                }
            }

            return project;
        }
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:46,代码来源:Project.cs


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