Click here to Skip to main content
15,885,868 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Need to call this : log.exe port13.dat StringTable > porttest.txt
Posted

You may use .NET Process[^] class to run such command...
C#
Process.Start("log.exe", "port13.dat");
 
Share this answer
 
In general, for every call to outside program, you use Process and ProcessStartInfo classes. If there is a default program set for particular file type you could even call the process directly, only with file name. Process.Start("test.txt") would open Notepad++ on my computer for example.

For your particular problem:

C#
using System;
using System.Diagnostics;

public class Processing
{
    public static void Main()
    {
        Process p = new Process();
        p.StartInfo.FileName = "log.exe";
        p.StartInfo.Arguments = "port13.dat StringTable > porttest.txt";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.Start();

        string output = p.StandardOutput.ReadToEnd();
        p.WaitForExit(); // This waits until the program called is closed

        Console.WriteLine("Output:");
        Console.WriteLine(output);    
    }
}


If this helps, please take time to accept the solution so that others may find it. Thank you.
 
Share this answer
 
v2
Comments
Gokulnath007 17-Sep-14 3:11am    
It doesnt work.
Sinisa Hajnal 17-Sep-14 3:21am    
And this comment does not help me to help you. Which part doesn't work? What error do you get? Do you have log.exe in the same directory as your application (if not, change: UseShellExecute to true and give p.StartInfo.WorkingDirectory to the path of log.exe)

Please clarify your "It doesn't work". Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900