控制台输出 [英] console output

查看:99
本文介绍了控制台输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于C#来说还很陌生,我有一个作为控制台应用程序编写的程序,用于比较几个名为BASE文件夹和INPUT文件夹的文件夹中的文件.

通过Console.WriteLine命令在屏幕上的控制台中显示输出.

我想要做的是将搜索结果输出到文本文件,以便我可以打印结果

Being fairly new to C# I have a program that I have written as a console application that compares the files in a couple of folders named BASE folder and INPUT folder.

The output is displayed in the Console on the screen via the Console.WriteLine command.

What I want to be able to do is to output the results of the search to a text file so that I can print the results

Any tips for doing this would be really appreciated

推荐答案

您可以使用StreamWriter类,请参见文档页面中的示例代码[
You may use the StreamWriter class, see the sample code in the documentation page [^].

You may also leave the application as it stands and redirect the output on calling the executable.
For instance, suppose your application''s name is mycomp.exe, then issuing
mycomp.exe > result.txt


会将程序的输出重定向到result.txt文本文件.
:)


will redirect the output of your program to the result.txt text file.
:)


这篇关于控制台输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆