Thank you for your responses. I modified the code a bit to use an array as so:
Code: Select all
function get-configxml {
$array = New-Object System.Collections.ArrayList
[xml]$fileConfig = (get-content "c:\temp\WatchedFolder.cfg")
$script:configInfo = ($fileConfig.watch_folders.watch_folder_pair | select in,out,error)
$array.AddRange($configInfo)
#$datagrid1.DataSource = $configInfo
#$formCVisionServerStatus.Refresh
}
Note: I realize the last two lines are commented out, this is just to test the actual code.
The error I get now is:
Cannot convert argument "c", with value: "@{in=\\share\Import;
out=\\share\Export; error=\\share\Error}", for "AddRange" to type
"System.Collections.ICollection": "Cannot convert the "@{in=\\share\Import;
out=\\share\Export; error=\\share\Error}" value of type
"Selected.System.Xml.XmlElement" to type "System.Collections.ICollection"."
At line:5 char:1
+ $array.AddRange($configInfo)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
All I want to do is be able to modify the in, out and error directories of the xml config file. If I am way off base please let me know. Thank you guys.