Using GFix in a C # application

1

I'm developing a C # application and I need to pass GFix to a FireBird database, I thought about running a prompt window and passing the GFix commands to it, but I'm not getting it. Also I need to return a message to the user if the database is ok or corrupted, I do not know how to do that either. Thank you in advance, I hope you have understood.

    
asked by anonymous 25.11.2014 / 19:11

1 answer

1

This example demonstrates how, from C #, to run an external program / application and read the output or results of this program.

The code below triggers the Windows command prompt ( cmd.exe ) and passes it the command that should be executed (in this case, the command dir ).

In the Arguments property you can replace the dir command with the application of your interest (GFix with its parameters).

using System;
using System.Diagnostics;

public class RedirectingProcessOutput
{
    public static void Main()
    {
        Process p = new Process();
        p.StartInfo.FileName = "cmd.exe";
        p.StartInfo.Arguments = "/c dir *.cs";
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.RedirectStandardOutput = true;
        p.Start();

        string output = p.StandardOutput.ReadToEnd();
        p.WaitForExit();

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

This code has been copied from SO in English .

    
25.11.2014 / 21:31