I would suggest not using GetFiles, it will have to populate the entire array before the function returns, the EnumerateFiles is a much better choice for large file sets - this is mentioned in the documentation by Microsoft.