Quantcast
Channel: How do I use Join-Path to combine more than two strings into a file path? - Stack Overflow
Browsing latest articles
Browse All 11 View Live

Answer by Marcus Mangelsdorf for How do I use Join-Path to combine more than...

Since PowerShell 6.0, Join-Path has a new parameter called -AdditionalChildPath and can combine multiple parts of a path out-of-the-box. Either by providing the extra parameter or by just supplying a...

View Article



Answer by Jon for How do I use Join-Path to combine more than two strings...

Here are two more ways to write a pure PowerShell function to join an arbitrary number of components into a path.This first function uses a single array to store all of the components and then a...

View Article

Answer by Daniel for How do I use Join-Path to combine more than two strings...

The following approach is more concise than piping Join-Path statements:$p = "a"; "b", "c", "d" | ForEach-Object -Process { $p = Join-Path $p $_ }$p then holds the concatenated path 'a\b\c\d'.(I just...

View Article

Answer by Kevin for How do I use Join-Path to combine more than two strings...

Or you could write your own function for it (which is what I ended up doing).function Join-Path-Recursively($PathParts) { $NumberOfPathParts = $PathParts.Length; if ($NumberOfPathParts -eq 0) { return...

View Article

Answer by Francesco for How do I use Join-Path to combine more than two...

You can use it this way:$root = 'C:'$folder1 = 'Program Files (x86)'$folder2 = 'Microsoft.NET'if (-Not(Test-Path $(Join-Path $root -ChildPath $folder1 | Join-Path -ChildPath $folder2))){"Folder does...

View Article


Answer by Mike Fair for How do I use Join-Path to combine more than two...

Here's something that will do what you'd want when using a string array for the ChildPath.$path = "C:"@( "Program Files", "Microsoft Office" ) | %{ $path = Join-Path $path $_ }Write-Host $pathWhich...

View Article

Answer by Konstantin Spirin for How do I use Join-Path to combine more than...

If you are still using .NET 2.0, then [IO.Path]::Combine won't have the params string[] overload which you need to join more than two parts, and you'll see the error Cannot find an overload for...

View Article

Answer by David Keaveny for How do I use Join-Path to combine more than two...

Since Join-Path can be piped a path value, you can pipe multiple Join-Path statements together:Join-Path "C:" -ChildPath "Windows" | Join-Path -ChildPath "system32" | Join-Path -ChildPath "drivers"It's...

View Article


Answer by Mark Toman for How do I use Join-Path to combine more than two...

You can use the .NET Path class:[IO.Path]::Combine('C:\', 'Foo', 'Bar')

View Article


Answer by Matt for How do I use Join-Path to combine more than two strings...

Join-Path is not exactly what you are looking for. It has multiple uses but not the one you are looking for. An example from Partying with Join-Path:Join-Path C:\hello,d:\goodbye,e:\hola,f:\adios...

View Article

How do I use Join-Path to combine more than two strings into a file path?

If I want to combine two strings into a file path, I use Join-Path like this:$path = Join-Path C: "Program Files"Write-Host $pathThat prints "C:\Program Files". If I want to do this for more than two...

View Article
Browsing latest articles
Browse All 11 View Live




Latest Images