I am trying to get mercurial to run in a shell from my C # wpf application. My goal is to extract the output to a string so that I can parse it.
Unfortunately, it seems to me that hg.exe (from tortoiseHg) does not return anything through the code below. Other .exe seem to work as seen in the comments below;
My code is below;
`
string workingDir = ""; string filename = ""; string param = ""; //This works workingDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); filename = "unrar.exe"; param = ""; //this works workingDir = "c:\\program files\\WinRar"; filename = "unrar.exe"; param = ""; //this works workingDir = "C:\\Program Files (x86)\\TortoiseHg"; filename = "docdiff.exe"; param = ""; //this does not work. I get a null returned. Why? workingDir = "C:\\Program Files (x86)\\TortoiseHg"; filename = "hg.exe"; param = ""; //this does not work. I get a null returned. Why? workingDir = "C:\\Program Files (x86)\\TortoiseHg"; filename = "hg.exe"; param = "help"; string retVal = ""; System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.WorkingDirectory = workingDir; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.FileName = filename; proc.StartInfo.Arguments = param; proc.Start(); System.IO.StreamReader reader = proc.StandardOutput; retVal = reader.ReadToEnd(); System.Windows.MessageBox.Show(retVal);`
If anyone can guess why this code is not working, or alternatively another way to get mercurial command line output, I would really appreciate it.
thanks
c # mercurial tortoisehg
Obbles
source share