我是 PowerShell 新手,对自己在编写新函数等方面取得的进展感到非常满意,但这一个让我难住了,这么简单的事情......
下面是函数:
Function fnConcatenatePathFile ([String]$Path, [String]$File)
{
$FullPath = "$($Path)\$($File)"
Return $FullPath
}
然后我像这样调用该函数:
fnConcatenatePathFile ("C:\_Store", "run.sql")
我期望的结果是:
"C:\_Store\run.sql"
但我得到的是:
"C:\_Store run.sql\"
快把我逼疯了……有什么线索吗?
最佳答案
Frode F. 已经 showed you你做错了什么。然而,有一个Join-Path用于组合路径的 cmdlet:
Join-Path "C:\_Store" "run.sql"
输出:
C:\_Store\run.sql
关于function - 连接路径和文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39436094/