连接路径和文件

Max*_*ate 3 variables powershell function

我是PowerShell的新手,我很高兴我在编写新功能等方面有多远,但是这个让我难过,这么简单......

以下是功能:

Function fnConcatenatePathFile ([String]$Path, [String]$File)
{
   $FullPath = "$($Path)\$($File)"
   Return $FullPath
}
Run Code Online (Sandbox Code Playgroud)

然后我调用这个函数:

fnConcatenatePathFile ("C:\_Store", "run.sql")
Run Code Online (Sandbox Code Playgroud)

我希望结果如下:

"C:\_Store\run.sql"
Run Code Online (Sandbox Code Playgroud)

但相反,我得到:

"C:\_Store run.sql\"
Run Code Online (Sandbox Code Playgroud)

让我疯狂......任何线索?

Mar*_*ndl 6

Frode F.已经告诉你你做错了什么.但是,有一个Join-Path cmdlet用于组合路径:

Join-Path "C:\_Store" "run.sql"
Run Code Online (Sandbox Code Playgroud)

输出:

C:\_Store\run.sql
Run Code Online (Sandbox Code Playgroud)