question

AnkiItwizard5-8193 avatar image
0 Votes"
AnkiItwizard5-8193 asked ZhiLv-MSFT commented

string result_pro = proc.StandardOutput.ReadToEnd(); this statement gives null string? Anyone know the reason why ?

Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.StartInfo.CreateNoWindow = true;
proc.EnableRaisingEvents = true;
proc.StartInfo.RedirectStandardOutput = true;

                 proc.Start();
                    
                 string result_pro = proc.StandardOutput.ReadToEnd();
                 proc.WaitForExit();
dotnet-csharpdotnet-aspnet-core-mvc
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ZhiLv-MSFT avatar image
0 Votes"
ZhiLv-MSFT answered ZhiLv-MSFT commented

Hi @AnkiItwizard5-8193,

The Process.StandardOutput Property gets a stream used to read the textual output of the application.

The issue might relate the procStartInfo, please check the executable file or document which used to start the process, make sure it has the textual output.

For example:

Create a Console application and have a textual output:

 namespace Write500Lines
 {
     public class Program
     {
         public static void Main(string[] args)
         {
             Console.WriteLine("Hello World!");
         }
     }
 }

Then use Process to get the output, the result as below:

110780-image.png



If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best Regards,
Dillion



image.png (41.9 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

But StandardOutput giving null string
as u show in output hello world but in my case not showing any output

0 Votes 0 ·

Hi @AnkiItwizard5-8193,

Have you ever checked the executable file or document which used to start the process, whether it has the textual output or not? Make sure the executable file or document is the latest version.

0 Votes 0 ·