Using Gfix in a C#

Asked

Viewed 197 times

1

I am developing an application in C# and I need to pass the Gfix in a Firebird database, I thought to run a prompt window and pass the commands of Gfix to her, but I am not succeeding. Also I need to return a message to the user if the database is ok or corrupted, if not how to do that too. Thanks in advance, I hope you understand.

1 answer

1

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

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

On the estate Arguments you can replace the command say by the application of your interest (Gfix with their respective 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 was copied from ONLY in English.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.