1

I'm currently building a WPF application. I want to be able to choose a binary file, decode it using the command prompt command line arguments into a .csv file, edit its value in my application then decode it back to a binary file using a decoding tool.The only part where I'm stuck at is entering my commandline arguments into the command prompt. I googled stuff, but I could only find information on how to open the command prompt from code and not how to execute a command.

Any help would be greatly appreciated. thanks!

PuZZled
  • 23
  • 2
  • 4

1 Answers1

4

checkout Process class, it is part of the .NET framework - for more information and some sample code see its documentation at MSDN.

EDIT - as per comment:

sample code that start 7zip and reads StdOut

using System;
using System.Diagnostics;
using System.IO;

class Program
{
    static void Main()
    {
    ProcessStartInfo start = new ProcessStartInfo();
    start.FileName = @"C:\7za.exe"; // Specify exe name.
    start.UseShellExecute = false;
    start.RedirectStandardOutput = true;

    using (Process process = Process.Start(start))
    {
        // Read in all the text from the process with the StreamReader.
        using (StreamReader reader = process.StandardOutput)
        {
        string result = reader.ReadToEnd();
        Console.Write(result);
        }
    }
    }
}

some links to samples:

Community
  • 1
  • 1
Yahia
  • 69,653
  • 9
  • 115
  • 144