powershell – How do I use join-path to combine more than two strings into a file path? – Stack Overflow
Posted by jpluimers on 2019/07/25
I love the solution with piped Join-Path constructs answered by David Keaveny in [WayBack] powershell – How do I use join-path to combine more than two strings into a file path? – Stack Overflow:
Since Join-Path can be piped its path value, you can pipe multiple Join-Path statements together:
Join-Path "C:" -ChildPath "Windows" | Join-Path -ChildPath "system32" | Join-Path -ChildPath "drivers"
Of course you could replace the built-in [WayBack] Join-Path by using using the .NET Framework [WayBack] Path.Combine Method (System.IO), but then you loose code completion.
If you do like that, here is how:
[System.IO.Path]::Combine("C:", "Windows", "system32", "drivers")
–jeroen






Leave a comment