我有一个DataGrid
( $myWindow.myDataGrid.Items
),我正在尝试Export-Clixml
。The$myWindow.myDataGrid.Items
是一个ItemCollection
包含String
具有某些字符的单词的属性,例如“C'Thun”或“-Hello”。要访问我当前正在查看的字符串,我键入$myWindow.myDataGrid.Items[0].Title
它会给我字符串“C'Thun”。
我使用的命令是:
$myWindow.myDataGrid.Items | Export-Clixml -path $path
当它被导出时,它们被翻译成其他字符。在记事本++中,“'”和“—”分别显示为“x91”和“x97”。我在导出之前检查了数组,文本是准确的,但是导出后,我检查了XML文件,文本全部转换了。我需要保留所有原始字符。
然后我使用这个命令,Import-Clixml
回到我的DataGrid
:
$Global:items = [Object[]]Import-Clixml -path $path
$myWindow.myDataGrid.ItemsSource = $Global:items
我在 at 处设置了一个断点,$Global:items = [Object[]]Import-Clixml -path $path
以查看$Global:items[0].title
导入时 at 的值是多少,果然,它是一个?
. 中的值DataGrid
也是?
。
我在powershell版本4上。
编辑:更改了一些细节。抱歉,添麻烦了。我在 2 个不同的系统上,无法复制和粘贴。