How to redirect justDecompile.exe output

2 posts, 0 answers
  1. Kyle
    Kyle avatar
    1 posts
    Member since:
    Oct 2012

    Posted 18 Oct 2012 Link to this post

    Using Windows XP I am able to run justDecomplie.exe /lang:cshare /target:<.exe or .dll> /out:c:\somedir from the command line.
    But when I try to redirect the justDecompile.exe using the ">log.txt" standard out operator or "2>log.txt" standard error operator I am unable to get a handle on the justDecompile output that is displayed to the command prompt terminal.

    How can I save the justDecompile.exe output that is sent to the command prompt terminal to a file?   
  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 22 Oct 2012 Link to this post

    Hi,

     Check the following example bellow, which can help you redirecting the console output to a different reader:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    using System.IO;
     
    namespace ConsoleApplication1
    {
        class Program
        {
            private static StreamWriter consoleWriter;
     
            static void Main(string[] args)
            {
                consoleWriter = File.AppendText(@"C:\Users\username\Desktop\output.txt");
     
                consoleWriter.AutoFlush = true;
     
                var processStartInfo = new ProcessStartInfo(@"C:\Telerik\JustDecompile\Libraries\JustDecompile.exe",
                                                            @"/out C:\Users\username\Desktop\output /target C:\assembly.dll");
     
                processStartInfo.RedirectStandardOutput = true;
                processStartInfo.UseShellExecute = false;
     
                var process = new Process { StartInfo = processStartInfo };
     
                process.OutputDataReceived += OnOutputDataReceived;
     
                process.Start();
     
                process.BeginOutputReadLine();
     
                process.WaitForExit();
            }
     
            static void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
            {
                consoleWriter.WriteLine(e.Data);
            }
        }
    }

    All the best,
    Kaloyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top