0

我使用下一个代码在控制台中打印进度。但是由于我使用快速编辑模式,如果我在控制台黑色区域内单击,则会出现白色光标并且我的应用程序处于挂起状态。如何防止这种行为继续使用快速编辑模式?

public static void WriteTheSameLine(String message)
{
    Console.CursorLeft = 0;
    int maxCharacterWidth = Console.WindowWidth - 1;
    if (message.Length > maxCharacterWidth)
    {
        message = message.Substring(0, maxCharacterWidth - 3) + "...";
    }
    message = message + new string(' ', maxCharacterWidth - message.Length);
    Console.Write(message);
}
4

1 回答 1

4

这里最底层的答案似乎可以解释它。

Your CMD windows is in quick edit mode which automatically enter the edit mode when you click on the screen. The Enter is for copy the text in the white-box and exit the edit mode. Normally CMD only enter edit mode when you right click on the black screen and choose Mark. To change back to normal, right click on the title bar of the windows and choose Properties, select Options tab and deselect "Quick Edit Mode" and click ok.

于 2013-09-23T12:55:27.493 回答