Exemple d’utilisation de la class ‘Process’ pour lancer et rediriger une processus locale

Author:

Utilitaire,Plateforme:,non,edité
{filelink=17867}

using System;
using System.Diagnostics;

public class ExempleProcess
{
    public static void Main()
    {
        Process process = new Process();
        process.StartInfo.FileName = "cmd.exe";
        // Argument de ligne de commande
        process.StartInfo.Arguments = "/c dir *.cs";
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.RedirectStandardOutput = true;
        process.Start();

        string output = process.StandardOutput.ReadToEnd();

        Console.WriteLine("Affichage:n{0}",output);
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *