[System.IO.Path]::Combine 不将我的 powershell 变量作为参数? [英] [System.IO.Path]::Combine not taking my powershell variable as a parameter?
本文介绍了[System.IO.Path]::Combine 不将我的 powershell 变量作为参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么函数 [System.IO.Path]::Combine
不接受我的第一个参数?
Why isn't the function [System.IO.Path]::Combine
taking my first parameter?
PS C:\WINDOWS\system32> $g_basePath
F:\Dev\OneClickTools
PS C:\WINDOWS\system32> [Tests.Utils]::CUSTOMASSEMBLY_TEST
CustomLogic.dll
PS C:\WINDOWS\system32> [System.IO.Path]::Combine($g_basePath, "\bin\debug", [Tests.Utils]::CUSTOMASSEMBLY_TEST)
\bin\debug\CustomLogic.dll
第三个命令显示只有第二个和第三个参数被连接还是使用空字符串作为 $g_basePath
..?
The third command shows that only the second and third parameters were concatenated or is it using an empty string as $g_basePath
..?
推荐答案
只需省略第二条路径中的前导反斜杠:
[System.IO.Path]::Combine($g_basePath, "bin\debug", [Tests.Utils]::CUSTOMASSEMBLY_TEST)
<小时>
纯粹的 PowerShell 尝试是使用 Join-path cmdlet 两次:
A pure PowerShell attempt would be to use the Join-path cmdlet twice:
Join-Path $g_basePath 'bin\debug' | Join-path -ChildPath [Tests.Utils]::CUSTOMASSEMBLY_TEST
这篇关于[System.IO.Path]::Combine 不将我的 powershell 变量作为参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文