惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
小众软件
小众软件
T
Tailwind CSS Blog
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
V
Visual Studio Blog
罗磊的独立博客
有赞技术团队
有赞技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
量子位
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
Hugging Face - Blog
Hugging Face - Blog
P
Proofpoint News Feed
N
Netflix TechBlog - Medium
GbyAI
GbyAI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
美团技术团队

博客园 - 珂儿

谈话技巧 用户中心 - 博客园 用户中心 - 博客园 【转载】 正则表达式 致谢 转载:Prototype.js的中文使用手册 Notes of Store Procedure 猫猫感冒了 从我的衣着改变说起 天无绝人之路 Job hunting准备系列一——关于搜索引擎技术 读书疑问汇总 算法题目汇总 How to influence people and win friends 项目经历总结——IBM实习总结 C++程序设计学习笔记 求职经验汇总 《编程之美》笔记
C# Program Output Redirect
珂儿 · 2009-02-06 · via 博客园 - 珂儿

These days I met with a problem. I have to run a program that my collegue developed, however, the program displayed its debug information on the console screen (standard output). and I want to store these debug information to some file since I need to use the these information to do some research work. We suppose the .exe file name is "a" here, so I opend cmd.exe, input "a.exe > output.txt" (output.txt is the file I want to use to store debug information), however, the program crashed and threw an exception saying the following words:

The handle is invalid.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
   at System.Console.GetBufferInfo()
   at System.Console.Clear()
   at Caller.Invoke()

we can see from the bold red words, in the program, it invoked a method called Console.clear() when it displayed debug info on console screen. However, while we redirected the output to a file, the program could not invoke Console.clear() method correctly then. Although it could redirect all the Console.writeline() or Console.write() to File Output, it could not redirect Console clear to File clear!

However, I still do not know why it could not finish this, if some one knows, please tell me why and thank you so much!