首页 > 解决方案 > 将exe输出实时保存到文本文件

问题描述

我有一个连接到服务器并实时输出结果的 exe 文件。有什么办法,使用 Windows,我可以将此 exe 输出的结果存储到文本文件中,并以半实时方式更新?我试过example.exe > log.txt了,但它返回

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at MinecraftClient.ConsoleIO.Write(String text)
   at MinecraftClient.ConsoleIO.WriteLine(String line)
   at MinecraftClient.McTcpClient.OnConnectionLost(DisconnectReason reason, String message)
   at MinecraftClient.Protocol.Handlers.Protocol18Handler.Updater()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

标签: c++windowsexeminecraft

解决方案


You can use something like that:

mycommand.exe param 2>&1 > myfile.txt

And it will create the myfile.txt at startup and fill it.

The 2 correspond to error log, and &1 add basic log (not debug).

More informations


推荐阅读