2016-09-20 09:46:02 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
param(
|
|
|
|
[ValidateNotNullOrEmpty()]
|
|
|
|
[Parameter(Mandatory=$true)][string]$startingDir,
|
|
|
|
[ValidateNotNullOrEmpty()]
|
|
|
|
[Parameter(Mandatory=$true)][string]$filename
|
|
|
|
)
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$currentDir = $startingDir
|
|
|
|
|
|
|
|
while (!($currentDir -eq "") -and !(Test-Path "$currentDir\$filename"))
|
|
|
|
{
|
2017-02-24 07:57:22 +08:00
|
|
|
Write-Verbose "Examining $currentDir for $filename"
|
2016-09-20 09:46:02 +08:00
|
|
|
$currentDir = Split-path $currentDir -Parent
|
|
|
|
}
|
2017-02-24 07:57:22 +08:00
|
|
|
Write-Verbose "Examining $currentDir for $filename - Found"
|
2016-09-20 09:46:02 +08:00
|
|
|
return $currentDir
|