I have a winforms application. I would like to run the .exe from the commandline and redirect the output from one of the output textboxes to the commandline. I don't want to launch the winform application just run the logic in the background.
I tried the advice from this thread
C# application both GUI and commandline
but I didn't see any of my console.writeline messages in the command line in cmd.exe when I ran the application via the cmd.exe. Can anyone guide me as to what I might be doing wrong?
I have an if statement that did this logic:
  if(args.Length >0)
   {
     Console.writeline("this has arguments");
     new Mainform();
   }
  else
   {
    Application.EnableVisualStyles();
    Application.Run(new MainForm());
   }
The else part still works. But nothing happens in the if part either using the cmd.exe to run the application or when I use the properties ->debug->command line arguments and give it arguments to run while debugging it. I have no idea what I am doing wrong.