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

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

问题描述

就是这样。我在这里找到了一个类似的问题: c#c​​onsole,Console.Clear问题



更新:



p> Console.Clear()throws:IOException(句柄无效)



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

解决方案

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



你有什么样的应用程序?



更新:



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


Just that. I found a similar question here : c# console, Console.Clear problem

but that didn't answer the question.

UPDATES :

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

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

解决方案

Console.Clear() works in a console application.

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

What kind of application do you have?

Update:

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天全站免登陆