{"id":22075722,"url":"https://github.com/trigger-segfault/triggerstools.filefind","last_synced_at":"2026-05-04T02:39:51.829Z","repository":{"id":87735818,"uuid":"147377100","full_name":"trigger-segfault/TriggersTools.FileFind","owner":"trigger-segfault","description":"An improvement on Window's existing .NET Framework API for finding files.","archived":false,"fork":false,"pushed_at":"2018-12-25T21:24:47.000Z","size":46,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T13:02:58.062Z","etag":null,"topics":["directory","enumerate","file","find","search","system","windows"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trigger-segfault.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-04T16:38:34.000Z","updated_at":"2024-04-16T11:13:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"7490e97a-5815-4966-987c-b060368fcd60","html_url":"https://github.com/trigger-segfault/TriggersTools.FileFind","commit_stats":null,"previous_names":["trigger-death/triggerstools.filefind"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trigger-segfault%2FTriggersTools.FileFind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trigger-segfault%2FTriggersTools.FileFind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trigger-segfault%2FTriggersTools.FileFind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trigger-segfault%2FTriggersTools.FileFind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trigger-segfault","download_url":"https://codeload.github.com/trigger-segfault/TriggersTools.FileFind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245162194,"owners_count":20570692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["directory","enumerate","file","find","search","system","windows"],"created_at":"2024-11-30T22:11:05.126Z","updated_at":"2026-05-04T02:39:51.737Z","avatar_url":"https://github.com/trigger-segfault.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TriggersTools.FileFind ![AppIcon](https://i.imgur.com/UUPIODl.png)\n\n[![NuGet Version](https://img.shields.io/nuget/v/TriggersTools.FileFind.svg?style=flat)](https://www.nuget.org/packages/TriggersTools.FileFind/)\n[![NuGet Downloads](https://img.shields.io/nuget/dt/TriggersTools.FileFind.svg?style=flat)](https://www.nuget.org/packages/TriggersTools.FileFind/)\n[![Creation Date](https://img.shields.io/badge/created-september%202018-A642FF.svg?style=flat)](https://github.com/trigger-death/TriggersTools.FileFind/commit/251837eca13d99d4db9af923b1932e5f8b79c5ac)\n[![Discord](https://img.shields.io/discord/436949335947870238.svg?style=flat\u0026logo=discord\u0026label=chat\u0026colorB=7389DC\u0026link=https://discord.gg/vB7jUbY)](https://discord.gg/vB7jUbY)\n\nAn improvement on Window's existing .NET Framework API for finding files. Enumeration no longer fails when encountering a secure file. File numeration is a little bit faster. Added support for matching file names by Regex.\n\n## General Info\n\nThe static class `FileFind` works very similarly to how `Directory` and `DirectoryInfo`'s enumerations work. To allow returning a preconstructed `FileInfo`/`DirectoryInfo`, `FileFind` uses its own class called `FileFindInfo`.\n\n`FileFindInfo` contains the following properties:\n\n```cs\nclass FileFindInfo {\n    string FullName { get; }\n    string Name { get; }\n    long Size { get; }\n    FileAttributes Attributes { get; }\n    DateTime CreationTimeUtc { get; }\n    DateTime CreationTime { get; }\n    DateTime LastAccessTimeUtc { get; }\n    DateTime LastAccessTime { get; }\n    DateTime LastWriteTimeUtc { get; }\n    DateTime LastWriteTime { get; }\n    bool IsDirectory { get; }\n    bool IsSymbolicLink { get; }\n}\n```\n\n## Basic Example\n\nBasic examples of enumerating file paths/infos or getting the same result as an array.\n\n```cs\nusing TriggersTools.IO.Windows;\n\n// List all files in the source directory\nforeach (string file in FileFind.EnumerateFiles(\"Source\", \"*.cs\", SearchOrder.AllDirectories))\n    Console.WriteLine(file);\n\n// Get an array of the same files as FileFindInfos\nFileFindInfo[] infos = FileFind.GetFileInfos(\"Source\", \"*.cs\", SearchOrder.AllDirectories);\n\n// Count the total number of items and size of every item in the C: drive.\nlong totalItems = 0;\nlong totalSize = 0;\n// Use depth order search, folders with 4 ancestores\n// will be scanned before folder with 5 ancestores.\nforeach (string file in FileFind.EnumerateFileSystemInfos(@\"C:\\\", \"*\", SearchOrder.AllDepths)) {\n    totalItems++;\n    totalSize += file.Size;\n}\nConsole.WriteLine($\"Total Items: {totalItems:N0}\");\nConsole.WriteLine($\"Total Bytes: {totalSize:N0}\");\n```\n\n### About SearchOrder\n\nUnlike .NET's `SearchOption` of `TopDirectoryOnly` or `AllDirectories` with enumerating files, `FileFind` comes with 4 modes under the `SearchOrder` enumeration.\n\n**Example File Tree:**\n\n```\n+ C:\\\n|-+ Program Files\n| '-+ Paint.NET\n|   |-+ Effects\n|   | '-- Alpha2Gray.dll\n|   |-- PaintDotNet.Core.dll\n|   '-- PaintDotNet.exe\n|-+ Users\n| |-+ Trigger\n| | |-+ Desktop\n| | | '-- My Documents.lnk\n| | '-- .gitconfig\n| '-+ Public\n|   |-- Public Documents\n|   '-- Public Downloads\n|-- hyberfil.sys\n'-- pagefile.sys\n```\n* **TopDirectoryOnly:** Includes only the current directory in a search operation.\n\n```\nEnumerateFileSystemEntries(@\"C:\\\", searchOrder: SearchOrder.TopDirectoryOnly);\n- C:\\Program Files\n- C:\\Users\n- C:\\hyberfil.sys\n- C:\\pagefile.sys\n```\n\n* **AllDirectories:** Each individual subdirectory is searched after the parent directory.\n\n```\nEnumerateFileSystemEntries(@\"C:\\\", searchOrder: SearchOrder.AllDirectories);\n- C:\\Program Files\n- C:\\Users\n- C:\\hyberfil.sys\n- C:\\pagefile.sys\n- C:\\Program Files\\Paint.NET\n- C:\\Program Files\\Paint.NET\\Effects\n- C:\\Program Files\\Paint.NET\\PaintDotNet.Core.dll\n- C:\\Program Files\\Paint.NET\\PaintDotNet.exe\n- C:\\Program Files\\Paint.NET\\Effects\\Alpha2Gray.dll\n- C:\\Users\\Trigger\n- C:\\Users\\Public\n- C:\\Users\\Trigger\\Desktop\n- C:\\Users\\Trigger\\.gitconfig\n- C:\\Users\\Trigger\\Desktop\\My Documents.lnk\n- C:\\Users\\Public\\Public Documents\n- C:\\Users\\Public\\Public Downloads\n```\n\n* **AllSubdirectories:** Each individual subdirectory is searched when it is encountered.\n\n```\nEnumerateFileSystemEntries(@\"C:\\\", searchOrder: SearchOrder.AllSubdirectories);\n- C:\\Program Files\n- C:\\Program Files\\Paint.NET\n- C:\\Program Files\\Paint.NET\\Effects\n- C:\\Program Files\\Paint.NET\\Effects\\Alpha2Gray.dll\n- C:\\Program Files\\Paint.NET\\PaintDotNet.Core.dll\n- C:\\Program Files\\Paint.NET\\PaintDotNet.exe\n- C:\\Users\n- C:\\Users\\Trigger\n- C:\\Users\\Trigger\\Desktop\n- C:\\Users\\Trigger\\Desktop\\My Documents.lnk\n- C:\\Users\\Trigger\\.gitconfig\n- C:\\Users\\Public\n- C:\\Users\\Public\\Public Documents\n- C:\\Users\\Public\\Public Downloads\n- C:\\hyberfil.sys\n- C:\\pagefile.sys\n```\n\n* **AllDepths:** Each individual subdirectory is searched in the order of their depth.\n\n```\nEnumerateFileSystemEntries(@\"C:\\\", searchOrder: SearchOrder.AllDepths);\n- C:\\Program Files\n- C:\\Users\n- C:\\hyberfil.sys\n- C:\\pagefile.sys\n- C:\\Program Files\\Paint.NET\n- C:\\Users\\Trigger\n- C:\\Users\\Public\n- C:\\Program Files\\Paint.NET\\Effects\n- C:\\Program Files\\Paint.NET\\PaintDotNet.Core.dll\n- C:\\Program Files\\Paint.NET\\PaintDotNet.exe\n- C:\\Users\\Trigger\\Desktop\n- C:\\Users\\Trigger\\.gitconfig\n- C:\\Users\\Public\\Public Documents\n- C:\\Users\\Public\\Public Downloads\n- C:\\Program Files\\Paint.NET\\Effects\\Alpha2Gray.dll\n- C:\\Users\\Trigger\\Desktop\\My Documents.lnk\n```\n\n## Regex Search\n\n`FileFind` also allows the use of directly passing Regex for searching.\n\n```cs\n// Match 2018 photos following a yyyy-mm-dd format\nRegex regex = new Regex(\\d{4}-\\d\\d?-\\d\\d?.*);\nvar files FileFind.EnumerateFiles(\"Camera\\2018\", regex, SearchOrder.AllDirectories);\nforeach (string file in files) {\n    // Do something with matched file...\n}\n```\n\n## Other Functions\n\n`FileFind` contains a few other functions that make use of `FileFind` P/Invoke.\n\n```cs\n// Get the info for the first matching file, returns null when nothing is found.\nFileFindInfo GetInfo(string path);\n\n// Gets the properly-cased name of the first matching file, return null when nothing is found.\nstring GetExactName(string path);\n\n// Gets the properly-cased path of the first matching file, return null when nothing is found.\nstring GetExactPath(string path);\n\n// Returns true if the directory contains no files. Throws Win32Exception if the directory could not be found.\nbool IsDirectoryEmpty(string directory);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrigger-segfault%2Ftriggerstools.filefind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrigger-segfault%2Ftriggerstools.filefind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrigger-segfault%2Ftriggerstools.filefind/lists"}