Created
March 24, 2022 15:09
-
-
Save stelf/3dccf2c96d666b4a5959ebc7619da272 to your computer and use it in GitHub Desktop.
Use System.IO.Directory to find files in .NET (faster than gci)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Find-Files { | |
[CmdletBinding()] | |
param( | |
[Parameter()] [string] $Glob, | |
[Parameter()] [string] $Path = (Get-Location)) | |
if (-not ( $Path -match '^\w:' ) ) { | |
$Path = (Get-Location).Path + '\' + $Path | |
} | |
Write-Host searching for $Glob in $Path. skip directories. | |
[System.IO.Directory]::EnumerateFiles( | |
$Path, $Glob, 'AllDirectories') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment