How to redirect a process output in direct ways?

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

    How to redirect a process output in direct ways?


    I have a console application that has huge outputs.

    I want to redirect the standard i/o to files, directly.
    but Process class has only process pipes.

    Do I have to CreateProcess API?
    I will use this code for server.

    Any Idea, please.

    Thank you.

  • Stanimir Stoyanov

    #2
    Re: How to redirect a process output in direct ways?

    You can use the Console.SetOut method to redirect output to a file stream
    but before the console application exits you should flush or close the
    stream to ensure that any data smaller than the default buffer is appended
    to the file.

    using System.IO;
    // ...
    StreamWriter stream = new StreamWriter(@" C:\temp\test.tx t");
    Console.SetOut( stream);

    stream.Close();

    --
    Stanimir Stoyanov
    메이저사이트 순위 먹튀검증이 완료된 토토사이트 커뮤니티 - 토토핫 입니다. 저희 토토핫에서는 베팅할때 필수로 점검해야 되는 안전 가이드를 제공하며 안전한 메이저 놀이터 목록과 메이저사이트 먹튀검증 꽁머니사이트를 추천드립니다.


    "free7942g" <free7942g@gmai l.comwrote in message
    news:106288fe-ff74-4d59-9526-6309d7de2fd0@v1 6g2000prc.googl egroups.com...
    >
    I have a console application that has huge outputs.
    >
    I want to redirect the standard i/o to files, directly.
    but Process class has only process pipes.
    >
    Do I have to CreateProcess API?
    I will use this code for server.
    >
    Any Idea, please.
    >
    Thank you.
    >

    Comment

    • free7942g

      #3
      Re: How to redirect a process output in direct ways?

      On 11¿ù1ÀÏ, ¿ÀÈÄ8½Ã42ºÐ, "Stanimir Stoyanov" <stoya....@REMO VETHIS.live.com >
      wrote:
      You can use the Console.SetOut method to redirect output to a file stream
      but before the console application exits you should flush or close the
      stream to ensure that any data smaller than the default buffer is appended
      to the file.
      >
      using System.IO;
      // ...
      StreamWriter stream = new StreamWriter(@" C:\temp\test.tx t");
      Console.SetOut( stream);
      >
      stream.Close();
      >
      --
      Stanimir Stoyanovhttp://stoyanoff.info
      >
      "free7942g" <free79...@gmai l.comwrote in message
      >
      news:106288fe-ff74-4d59-9526-6309d7de2fd0@v1 6g2000prc.googl egroups.com...
      >
      >
      >
      >
      >
      I have a console application that has huge outputs.
      >
      I want to redirect the standard i/o to files, directly.
      but Process class has only process pipes.
      >
      Do I have to CreateProcess API?
      I will use this code for server.
      >
      Any Idea, please.
      >
      Thank you.- µû¿Â ÅØ½ºÆ® ¼û±â±â -
      >
      - µû¿Â ÅØ½ºÆ® º¸±â -
      A problem was solved because of you.
      Oh, I am using a translation program.
      Thanks very much! :-)




      Comment

      • free7942g

        #4
        Re: How to redirect a process output in direct ways?

        On 11¿ù1ÀÏ, ¿ÀÈÄ8½Ã42ºÐ, "Stanimir Stoyanov" <stoyanov@REMOV ETHIS.live.com>
        wrote:
        You can use the Console.SetOut method to redirect output to a file stream
        but before the console application exits you should flush or close the
        stream to ensure that any data smaller than the default buffer is appended
        to the file.
        >
        using System.IO;
        // ...
        StreamWriter stream = new StreamWriter(@" C:\temp\test.tx t");
        Console.SetOut( stream);
        >
        stream.Close();
        >
        --
        Stanimir Stoyanovhttp://stoyanoff.info
        >
        "free7942g" <free7942g@gmai l.comwrote in message
        >
        news:106288fe-ff74-4d59-9526-6309d7de2fd0@v1 6g2000prc.googl egroups.com...
        >
        >
        >
        >
        >
        I have a console application that has huge outputs.
        >
        I want to redirect the standard i/o to files, directly.
        but Process class has only process pipes.
        >
        Do I have to CreateProcess API?
        I will use this code for server.
        >
        Any Idea, please.
        >
        Thank you.- µû¿Â ÅØ½ºÆ® ¼û±â±â -
        >
        - µû¿Â ÅØ½ºÆ® º¸±â -
        Oh, I am using translating software...
        Thanks very much! :-)

        Comment

        Working...