gpt4 book ai didi

c# - 在 C# 中将输出管道输出到文本文件

转载 作者:可可西里 更新时间:2023-11-01 11:21:53 26 4
gpt4 key购买 nike

我这里有一个方法,尽管我想将它的输出通过管道传输到一个文件,例如output.txt,我怎么能在这种情况下做到这一点?

  foreach (string tmpLine in File.ReadAllLines(@"c:\filename.txt"))
{
if (File.Exists(tmpLine))
{
//output
}
}

最佳答案

通常命令行明智,你做

mycommand > somefile.txt

mycommand | more

这是有效的,因为输出被写入标准输出。

你可以试试 http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx

关于c# - 在 C# 中将输出管道输出到文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6283114/

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