gpt4 book ai didi

.net - 如何使用 IO.File AppendAllLines

转载 作者:行者123 更新时间:2023-12-02 23:32:27 24 4
gpt4 key购买 nike

$text = "Hello","World"
[IO.File]::AppendAllLines(
"C:\test.txt",
$text,
[Text.Encoding]::Default
)
我得到错误:
'Cannot find an overload for "AppendAllLines" and the argument count: "3".'
如何解决? WriteAllLines 在使用相同参数时效果很好,但是这种方法有什么问题?

最佳答案

Powershell 遇到问题 $text因为类型是 object[]但该方法需要一个字符串可枚举。
投到 string[]第一的:


[string[]]$text = "Hello","World"

# or

[IO.File]::AppendAllLines(
"C:\test.txt",
[string[]]$text,
[Text.Encoding]::Default
)

关于.net - 如何使用 IO.File AppendAllLines,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64387381/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com