C# Directory.GetFileSystemEntries的代码示例
通过代码示例来学习C# Directory.GetFileSystemEntries方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
Directory.GetFileSystemEntries是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的Directory.GetFileSystemEntries() 已经帮大家高亮显示了,大家可以重点学习Directory.GetFileSystemEntries() 方法的写法,从而快速掌握该方法的应用。
Directory.GetFileSystemEntries的代码示例1 - CreatingFolderShouldAddToSparseListAndStartProjecting()
using System.IO; [TestCase, Order(6)] public void CreatingFolderShouldAddToSparseListAndStartProjecting() { this.gvfsProcess.AddSparseFolders(this.mainSparseFolder); this.ValidateFoldersInSparseList(this.mainSparseFolder); string newFolderPath = Path.Combine(this.Enlistment.RepoRoot, "GVFS", "GVFS.Common"); newFolderPath.ShouldNotExistOnDisk(this.fileSystem); Directory.CreateDirectory(newFolderPath); newFolderPath.ShouldBeADirectory(this.fileSystem); string[] fileSystemEntries = Directory.GetFileSystemEntries(newFolderPath); fileSystemEntries.Length.ShouldEqual(32); this.ValidateFoldersInSparseList(this.mainSparseFolder, Path.Combine("GVFS", "GVFS.Common")); string projectedFolder = Path.Combine(newFolderPath, "Git"); projectedFolder.ShouldBeADirectory(this.fileSystem); fileSystemEntries = Directory.GetFileSystemEntries(projectedFolder); fileSystemEntries.Length.ShouldEqual(13); string projectedFile = Path.Combine(newFolderPath, "ReturnCode.cs"); projectedFile.ShouldBeAFile(this.fileSystem); }
开发者ID:microsoft,项目名称:VFSForGit,代码行数:24,代码来源:SparseTests.cs
在CreatingFolderShouldAddToSparseListAndStartProjecting()方法中,Directory的代码示例类中的GetFileSystemEntries的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
Directory.GetFileSystemEntries的代码示例2 - ProcessDirectory()
private static void ProcessDirectory(string path, IFileHandler handler, string relativePath, TextWriter log) { var entries = System.IO.Directory.GetFileSystemEntries(path); // Order alphabetically so that output is stable across invocations Array.Sort(entries, string.CompareOrdinal); foreach (var entry in entries) { var file = Path.Combine(path, entry); if (System.IO.Directory.Exists(file)) { ProcessDirectory(file, handler, relativePath.Length == 0 ? new DirectoryInfo(entry).Name : relativePath + "/" + new DirectoryInfo(entry).Name, log); } else if (handler.ShouldProcess(file)) { handler.OnBeforeExtraction(file, relativePath, log); // Read metadata using var stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read); try { var directories = ImageMetadataReader.ReadMetadata(stream).ToList(); // ImageMetadataReader.ReadMetadata(Stream) doesn't add a FileMetadataReader directory. // Add it manually directories.Add(new FileMetadataReader().Read(file)); handler.OnExtractionSuccess(file, directories, relativePath, log, stream.Position); } catch (Exception e) { handler.OnExtractionError(file, e, log, stream.Position); } } } }
开发者ID:drewnoakes,项目名称:metadata-extractor-dotnet,代码行数:39,代码来源:Program.cs
在ProcessDirectory()方法中,Directory的代码示例类中的GetFileSystemEntries的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
Directory.GetFileSystemEntries的代码示例3 - Query()
using System.IO; public List
Query(Query query) { List results = new List (); string cmd = query.Search; if (string.IsNullOrEmpty(cmd)) { return ResultsFromHistory(); } else { var queryCmd = GetCurrentCmd(cmd); results.Add(queryCmd); var history = GetHistoryCmds(cmd, queryCmd); results.AddRange(history); try { string basedir = null; string dir = null; string excmd = Environment.ExpandEnvironmentVariables(cmd); if (Directory.Exists(excmd) && (cmd.EndsWith("/") || cmd.EndsWith(@"\"))) { basedir = excmd; dir = cmd; } else if (Directory.Exists(Path.GetDirectoryName(excmd) ?? string.Empty)) { basedir = Path.GetDirectoryName(excmd); var dirName = Path.GetDirectoryName(cmd); dir = (dirName.EndsWith("/") || dirName.EndsWith(@"\")) ? dirName : cmd.Substring(0, dirName.Length + 1); } if (basedir != null) { var autocomplete = Directory.GetFileSystemEntries(basedir) .Select(o => dir + Path.GetFileName(o)) .Where(o => o.StartsWith(cmd, StringComparison.OrdinalIgnoreCase) && !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase)) && !results.Any(p => o.Equals(p.Title, StringComparison.OrdinalIgnoreCase))).ToList(); autocomplete.Sort(); results.AddRange(autocomplete.ConvertAll(m => new Result { Title = m, IcoPath = Image, Action = c => { var runAsAdministrator = c.SpecialKeyState.CtrlPressed && c.SpecialKeyState.ShiftPressed && !c.SpecialKeyState.AltPressed && !c.SpecialKeyState.WinPressed; Execute(Process.Start, PrepareProcessStartInfo(m, runAsAdministrator)); return true; }, CopyText = m })); } } catch (Exception e) { Log.Exception($"|Flow.Launcher.Plugin.Shell.Main.Query|Exception when query for <{query}>", e); } return results; } }
开发者ID:Flow-Launcher,项目名称:Flow.Launcher,代码行数:71,代码来源:Main.cs
在Query()方法中,Directory的代码示例类中的GetFileSystemEntries的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
Directory.GetFileSystemEntries的代码示例4 - ClearMonitorTempFolder()
using System.IO; ///
/// Delete files in temp folder. /// public static void ClearMonitorTempFolder() { if (Directory.Exists(defaultMonitorTempFolder)) { foreach (string d in Directory.GetFileSystemEntries(defaultMonitorTempFolder)) { if (File.Exists(d)) { File.Delete(d); } } } }
开发者ID:huiyadanli,项目名称:PasteEx,代码行数:18,代码来源:PathGenerator.cs
在ClearMonitorTempFolder()方法中,Directory的代码示例类中的GetFileSystemEntries的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的Directory.GetFileSystemEntries方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。