Utilisation de la commande Process.StartInfo
Bonjour,
J'ai ce code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
string path = string.Format(@"{0}\gpg.exe", @"C:\Program Files\GNU\GnuPG");
Console.WriteLine(command);
var procStartInfo = new ProcessStartInfo(path, command)
{
WorkingDirectory = @"C:\Program Files\GNU\GnuPG",
CreateNoWindow = false,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true
};
var proc = new Process { StartInfo = procStartInfo };
proc.Start();
proc.StandardInput.Flush();
// Get the output into a string
string result = proc.StandardOutput.ReadToEnd();
string error = proc.StandardError.ReadToEnd(); |
Cela me permet de crypter via GPG des fichiers.
Donc cela revient à ouvrir une commande dos, et taper une ligne de commande avec des paramètres passés au programme GPG.Exe.
A l’exécution de la ligne
Code:
string result = proc.StandardOutput.ReadToEnd();
La commande DOS me demande de répondre par Oui ou non, afin que le programme se termine.
Je suis obligé de le faire manuellement, alors que j'aurai aimé que cela soit fait automatiquement par le programme....
Comment faire?
J'ai essayé un :
Code:
proc.standardInput.writeline("oui")
Mais en vain...
Merci par avance,