Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Redirecting Process Output

RSS
Modified on Mon, May 22, 2023, 6:27 AM by Administrator Categorized as ·Net Core, ·Net Framework
private static string GetGitBranch()
{
    var result = string.Empty;

    var psi = new ProcessStartInfo
    {
        Arguments = "/c git branch --show-current",
        FileName = "cmd.exe",
        WindowStyle = ProcessWindowStyle.Normal,
        RedirectStandardOutput = true
    };

    var p = Process.Start(psi);

    result = p.StandardOutput.ReadToEnd();

    p.WaitForExit();

    result = result.Replace("\n", string.Empty);

    return result;
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.