0

I try to send commend to cmd and get output. I'm sure it sent but I cannot get the output.

 ProcessStartInfo startinfo = new ProcessStartInfo();
        startinfo.FileName = @"C:\Users\mehmetcan\Desktop\adt-bundle-windows-x86-20130917\sdk\platform-tools\adb.exe";
        startinfo.Arguments = @"devices";
        startinfo.RedirectStandardOutput = true;
        startinfo.RedirectStandardError = true;
        startinfo.UseShellExecute = false;

        // Note: declare process as a variable in the class as it needs to be used in the event handlers
        process = new Process();
        process.StartInfo = startinfo;

It returns : "123456 devices " How can get it in a string?

cantas
  • 104
  • 1
  • 14
  • Eg is available in http://stackoverflow.com/questions/4587415/how-to-capture-shell-command-output-in-c . – srsyogesh Oct 26 '13 at 20:08

1 Answers1

1

You should read it via

string output = process.StandardOutput.ReadToEnd();
Nickolay Olshevsky
  • 13,706
  • 1
  • 34
  • 48
  • Doesnt work. It says : Cannot convert method group 'ReadToEnd' to non-delegate type 'string'. Did you intend to invoke the method? @Nickolay Olshevsky – cantas Oct 26 '13 at 20:53
  • An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll – cantas Oct 26 '13 at 21:10