ProcessStartInfo

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nospam

    #1

    ProcessStartInfo

    Hi,

    Can you let me know why this won't display the standard output on console?

    Thanks



    Process myProcess = new Process();

    ProcessStartInf o myProcessStartI nfo = new ProcessStartInf o("ipconfig" );

    myProcessStartI nfo.Arguments="/all";

    myProcessStartI nfo.UseShellExe cute = false;

    myProcessStartI nfo.RedirectSta ndardOutput = true;

    myProcess.Start Info = myProcessStartI nfo;

    myProcess.Start ();

    StreamReader myStreamReader = myProcess.Stand ardOutput;

    // Read the standard output of the spawned process.

    string myString = myStreamReader. ReadLine();

    Console.WriteLi ne(myString);

    myProcess.Close ();


  • gani

    #2
    Re: ProcessStartInf o

    hi,
    you just need to replace :
    string myString = myStreamReader. ReadLine();
    to
    string myString = myStreamReader. ReadToEnd();

    hope this helps.

    --
    gani
    pls visit http://thedeveloperscorner.com.ph




    "nospam" <hello@hotmail. com> wrote in message
    news:FYOdnQj-rZLaTeqiRVn-iw@giganews.com ...[color=blue]
    > Hi,
    >
    > Can you let me know why this won't display the standard output on console?
    >
    > Thanks
    >
    >
    >
    > Process myProcess = new Process();
    >
    > ProcessStartInf o myProcessStartI nfo = new ProcessStartInf o("ipconfig" );
    >
    > myProcessStartI nfo.Arguments="/all";
    >
    > myProcessStartI nfo.UseShellExe cute = false;
    >
    > myProcessStartI nfo.RedirectSta ndardOutput = true;
    >
    > myProcess.Start Info = myProcessStartI nfo;
    >
    > myProcess.Start ();
    >
    > StreamReader myStreamReader = myProcess.Stand ardOutput;
    >
    > // Read the standard output of the spawned process.
    >
    > string myString = myStreamReader. ReadLine();
    >
    > Console.WriteLi ne(myString);
    >
    > myProcess.Close ();
    >
    >[/color]


    Comment

    Working...