Fullscreen Console Window C# .NET 6.0 VS

DeltaCypher6479 1 Reputation point
2022-07-17T10:25:24.927+00:00

I am trying to create a command line app that uses a console window and I need it to be full screen (as if have pressed alt+enter, because all of the scripts I find are maximizing the window to your resolution) but all of the code I found is done in Windows Forms, I am not using windows forms because it is a console window.

I am on windows, using .NET 6.0 on VS.

Thank you,

Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2022-07-17T12:16:02.59+00:00

    See code in my repository, copy WindowUtility.cs. I use it by placing in a class project named ConsoleHelperLibrary in a folder named Classes.

    See this example

    Then once adding a reference to ConsoleHelperLibrary use it as follows

    namespace YourNamespaceGoesHere  
    {  
        partial class Program  
        {  
            [ModuleInitializer]  
            public static void Init()  
            {  
                W.SetConsoleWindowPosition(W.AnchorWindow.Fill);  
            }  
        }  
    }  
    

    Tip as in the above I have Program setup as a partial class and the above code would be in the following

    221470-figure1a.png

    For anyone reading this using .NET Core 5 you can use my NuGet package.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.