在Powershell中:我有2个列表-FontIDList和FontDefinitionList。我想使用FontID的第一行并添加FontDefinition的第一行。重复所有元素,然后写入文本文件。我试过了:
$newContent = $FontIDList2 | foreach {$_ + $FontDefList2}
Add-Content "C:\Desktop\MasterFontList-TimeStamps\TestLatestDate.txt" -value $newContent
以及$newContent = $FontIDList2 + FontDefList2
-和我很确定我需要使用某种foreach
,但不确定语法。
您可以通过索引而不是使用for
循环来进行迭代,然后连接字符串:
$newContent = for ($i = 0 ; $i -lt $FontIDList.Count ; $i++) {
$FontIDList[$i] + $FontDefList2[$i]
}
Add-Content "C:\Users\dtxxxxx\Desktop\MasterFontList-TimeStamps\TestLatestDate.txt" -value $newContent
请注意,这Add-Content
会添加到文件中,请不确定这是否是您真正想要的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句