如何清除C#.NET控制台? [英] How to clear the Console in c#.net?

查看:228
本文介绍了如何清除C#.NET控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一点。我发现了一个类似的问题在这里: http://stackoverflow.com/questions/377927/c-console -console-明确的问题

Just that. I found a similar question here : http://stackoverflow.com/questions/377927/c-console-console-clear-problem

但没有回答这个问题。

更新

Console.Clear()抛出:IOException(句柄无效)

Console.Clear() throws : IOException (The handle is invalid)

该应用程序是一个WPF应用程序。写然而控制台一点问题都没有的,也不是从阅读。

The app is a WPF app. Writing to the console however is no problem at all, nor is reading from.

推荐答案

Console.Clear ()工作在一个控制台应用程序。

Console.Clear() works in a console application.

Console.Clear()呼叫当在ASP.NET网站项目或在Windows窗体应用程序,那么你会得到IOException异常。

When Calling Console.Clear() in a ASP.NET web site project or in a windows forms application, then you'll get the IOException.

你有什么样的应用?

更新:

我不知道这是否会有所帮助,但你可以阅读的这个论坛主题 Console.Clear()抛出IOException如果控制台输出被重定向。也许这是一个WPF应用程序的情况下?本文介绍如何检查控制台是否被重定向。

I'm not sure if this will help, but as you can read in this forum thread, Console.Clear() throws an IOException if the console output is being redirected. Maybe this is the case for WPF applications? The article describes how to check whether the console is being redirected.

这篇关于如何清除C#.NET控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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