如果我有一个文本文件,C:\USER\Documents\Collections\collection.txt,其中包含以下信息:
collectionA.json
collectionB.json
collectionC.json
collectionD.json
我想知道如何通过 Powershell,将文本文件中的每一行存储为数组元素,例如...
我在想如何通过 PowerShell 将文本文件中的每一行作为数组元素存储,例如...
array arrayFromFile = new Array;
foreach(line x in collection.txt)
{
arrayFromFile.Add(x);
}
以以下目标为最终目的:
foreach(string x in arrayFromFile)
{
newman run x;
}
对于这个看似简单的问题,我深表歉意——我以前从未接触过Powershell。
$myArr = New-Object System.Collections.ArrayList
并使用相同的.Add
方法将其添加到其中,因为它们是动态的。 - Ste