Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Show results in console

Show results in console

Scheduled Pinned Locked Moved C#
csharpwinforms
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kash
    wrote on last edited by
    #1

    I want to output data to the console from a button click on my WinForms application. This is what I tried but with no call to the function aTest() was made. Process myProcess = new Process(); myProcess.StartInfo.FileName = "cmd"; myProcess.StartInfo.Arguments = "aTest()"; myProcess.StartInfo.UseShellExecute = true; myProcess.Start(); Thanks Kash

    D 1 Reply Last reply
    0
    • K Kash

      I want to output data to the console from a button click on my WinForms application. This is what I tried but with no call to the function aTest() was made. Process myProcess = new Process(); myProcess.StartInfo.FileName = "cmd"; myProcess.StartInfo.Arguments = "aTest()"; myProcess.StartInfo.UseShellExecute = true; myProcess.Start(); Thanks Kash

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      What you've done won't work. You've put together a command line that looks like this:

      CMD aTest()

      Try typing that into a Start/Run box. You'll find that it does the exact same thing as your code. CMD doesn't know what to do with aTest() because it's not a valid command line argument for CMD. CMD cannot call back into your code to execute a method. What I think you're trying to do is write to a console window that your application has complete control over. You can do this by redirecting the Streams of a CMD process. Check out this[^] article on MSDN, go about half way down the article, looking for Controlling Console Apps with the Process Class, and you'll see what I mean. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      K 1 Reply Last reply
      0
      • D Dave Kreskowiak

        What you've done won't work. You've put together a command line that looks like this:

        CMD aTest()

        Try typing that into a Start/Run box. You'll find that it does the exact same thing as your code. CMD doesn't know what to do with aTest() because it's not a valid command line argument for CMD. CMD cannot call back into your code to execute a method. What I think you're trying to do is write to a console window that your application has complete control over. You can do this by redirecting the Streams of a CMD process. Check out this[^] article on MSDN, go about half way down the article, looking for Controlling Console Apps with the Process Class, and you'll see what I mean. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        K Offline
        K Offline
        Kash
        wrote on last edited by
        #3

        Hi, I've read some material and tried a few things but still no success. If anyone has a snippet or small example; this would be very useful. Kash

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups