2

I can't be sure if this is an issue specific to Accurev, or is more to do with calling the command line from C#. I'll make the question and its tags more specific when I work out which it is.

I've got the following two calls that I can successfully make using command prompt :

  • accurev stat -d -s "ProductionSupport" -fx
  • accurev hist -s "ProductionSupport" -ftx -e "1570567"

And in both cases I can see xml as a result.

However I want to make these calls from a C# program, and the first one of those works great but inexplicably the second one returns an empty string.

    public string CallAccurev(string arguments)
    {
        Process cmdUtility = new Process
        {
            StartInfo =
            {
                FileName = "C:\\Program Files (x86)\\AccuRev v5.5\\bin\\accurev.exe",
                Arguments = arguments,
                UseShellExecute = false,
                RedirectStandardOutput = true,
                RedirectStandardError = true
            }
        };
        cmdUtility.Start();
        var s = cmdUtility.StandardOutput.ReadToEnd();
        cmdUtility.WaitForExit();
        return s;
    }

My calls look like this :

var checkInComment = CallAccurev("hist -s " + _streamName + " -e " + Convert.ToString(processedFile.TransId) + " -ftx");

var filesString = CallAccurev("stat -d -s " + _streamName + " -fex");

As an attempt to get around this I've tried putting my "hist" call and its parameters into a .Bat file. I can see that double clicking that file gives the intended behaviour but when I call it from code I get empty strings again.

Any answers or clues on how to debug what is happening during my hist call are greatly appreciated!

coderkerr
  • 65
  • 1
  • 8
  • `_streamName` - does it contain full path in your program? If it is not, can you try to feed full path? – Ulugbek Umirov Mar 30 '14 at 05:28
  • It doesn't contain the full path because it's not a stream on my machine - basically i'm looking to query the stream which is shared by the team (i.e., not a local workspace). Cheers – coderkerr Mar 30 '14 at 05:34

1 Answers1

2

I would think you would need to read the standard output AFTER the process has completed.

cmdUtility.WaitForExit();
var s = cmdUtility.StandardOutput.ReadToEnd();

However, reading Accurev output directly can sometimes overflow the buffer. You might want to investigate using asynchronous reading. How to spawn a process and capture its STDOUT in .NET?

Community
  • 1
  • 1
Matt Slagle
  • 1,075
  • 9
  • 19