我这里有一个方法,尽管我想将它的输出通过管道传输到一个文件,例如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/