This is a migrated thread and some comments may be shown as answers.

How to redirect justDecompile.exe output

1 Answer 18 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 18 Oct 2012, 07:21 PM
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?   

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 22 Oct 2012, 10:27 AM
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.

Tags
General Discussions
Asked by
Kyle
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or