0

我的文本文件内容如下

8.4.0.154

新队

我在批处理文件中写了下面的命令来读取第一行的意思是 8.4.0.154

set /p ClientSideUnitTestDestinationLocation=<%scriptLocation%\assemblyVersion.txt
Echo %ClientSideUnitTestDestinationLocation%

这里它只是打印 8 个带有一些特殊符号的前缀,如下图所示

仅打印 8 个带有一些特殊符号的前缀

谁能在这里帮我弄清楚为什么我无法读取批处理文件中的完整数字并将其打印出来。

提前致谢

4

1 回答 1

0

我正在使用以下命令使用 PowerShell 脚本创建此文本文件:

param ([string] $dllPath = $null,[string] $textFile = $null)
$version = [System.Reflection.Assembly]::LoadFrom($dllPath).GetName().Version.ToString()
$version > $textFile

文本文件未使用 ANSI 编码创建,因此无法使用批处理文件读取。

现在,我将上面的代码更改如下,它正在工作。

param ([string] $dllPath = $null,[string] $textFile = $null)
$version = [System.Reflection.Assembly]::LoadFrom($dllPath).GetName().Version.ToString()
$version | Out-File $textFile -Encoding Ascii

我可以使用以下命令读取文本文件内容

set /p ClientSideUnitTestDestinationLocation=<%scriptLocation%\assemblyVersion.txt
Echo %ClientSideUnitTestDestinationLocation%
于 2019-02-20T11:30:01.917 回答