Skip to content

Instantly share code, notes, and snippets.


frekac/Get-FilesQuickIO.ps1 Secret

Created Dec 15, 2016
What would you like to do?
Search file structure using QuickIO.Net library
Search the file structure without the 260+ character path length limit.
Get-FilesQuickIO -FilePath <path> -Filter "*.*" -Recursive
function Get-FilesQuickIO
# Path to start from
# To search recursively
# To filter
# Load QuickIO Assmebly
Add-Type -Path .\QuickIO\SchwabenCode.QuickIO.dll
# Initiate the file list
$fileList = @()
# Set search option based on recursive or not
if(($Recursive -eq $true) -and (($Filter -eq "*") -or ($Filter -eq "*.*")))
# Set the search option value
$searchOption = "AllDirectories"
# Get the list of files
$fileList = [SchwabenCode.QuickIO.QuickIODirectory]::EnumerateFiles([system.string]$FilePath,[system.string]$Filter,[System.IO.SearchOption]$searchOption)
elseif ($Recursive -eq $true)
# Set the search option value
$searchOption = "AllDirectories"
# Set the directory pattern
$directoryPattern = "*"
# Get all the directories as the recursive option doesn't work when using a filter.
$directoryList = [SchwabenCode.QuickIO.QuickIODirectory]::EnumerateDirectories([system.string]$FilePath,[system.string]$directoryPattern,[System.IO.SearchOption]$searchOption) | select -ExpandProperty FullName
# Loop through the directories with the file pattern
foreach($d in $directoryList)
$fileList += try{[SchwabenCode.QuickIO.QuickIODirectory]::EnumerateFiles([system.string]$d,[system.string]$Filter,[System.IO.SearchOption]$searchOption)}catch{$null}
# Set the search option value
$searchOption = "TopDirectoryOnly"
# Get the list of files
$fileList = try{[SchwabenCode.QuickIO.QuickIODirectory]::EnumerateFiles([system.string]$FilePath,[system.string]$Filter,[System.IO.SearchOption]$searchOption)}catch{$null}
return $fileList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment