Please help !

I've got to capture all the messages that a dos program is sending them to the console ! How can i do it
The program isn't supporting this opption, to output the messages in a text file.  Please help !!!!!


Answer this question

Please help !

  • speed32

    You can take a look at the Console class. For example:


    string line = Console.ReadLine();StreamWriter sw = new StreamWriter(@"c:\log.txt", true);sw.Write(line);sw.Close();
     


    This will read a line from the console and writes it to a file called log.txt.

  • Manni

    Mihai,

    how about simply redirecting text printed to stdout using '>'

    WM_HOPETHISHELPS
    thomas woelfer

  • Amit kr mishra

    This is easy - add System.Diagnostics and System.IO using clauses then use something similar to this:

    ProcessStartInfo pi = new ProcessStartInfo("cmd.exe", "/c dir");

    pi.WindowStyle = ProcessWindowStyle.Hidden;

    pi.RedirectStandardOutput = true;

    pi.UseShellExecute = false;

    Process p = Process.Start(pi);

    p.WaitForExit();

    p.Start();

    TextReader t = p.StandardOutput;

    MessageBox.Show(t.ReadToEnd());

    (sorry for the code being mangled, the forums editor seems to be doing it)



  • mizatch

    Glad I could help Smile

  • sarasotamac

    thanks Simon, i think this it's what have I searched for. thanks a lot
  • Please help !