How about something as simple as:
PS> gci . -r foo.txt
This implicitly uses the -filter parameter (by position) specifying foo.txt as the filter. You could also specify *.txt or foo?.txt. The problem with StartsWith is that while you handle the case-insensitive compare there is still the issue that both / and \ are valid path separators in PowerShell.
Assuming the file may not exist and both $file and $directory are absolute paths, you can do this the "PowerShell" way:
(Split-Path $file -Parent) -replace '/','\' -eq (Get-Item $directory).FullName
But that isn't great since you still have to canonical the path / -> \ but at least the PowerShell string compare is case-insensitive. Another option is to use IO.Path to canonicalize the path e.g.:
[io.path]::GetDirectoryName($file) -eq [io.path]::GetFullPath($directory)
One issue with this is that GetFullPath will also make a relative path an absolute path based on the process's current dir which more times than not, is not the same as PowerShell's current dir. So just make sure $directory is an absolute path even if you have to specify it like "$pwd\$directory".