且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用System.Diagnostic从我的C#程序运行.exe并使用C#向EXE发送数据和从EXE获取数据

更新时间:2022-11-01 21:57:32

可能有很多其他方法可以完成这项任务,下面是你可以采用的一种方法试试这个:



1.创建命令接受参数作为数字的行exe然后你可以计算该输入的因子并返回结果。检查以下参考资料

http://www.dotnetperls.com/main [ ^ ]

http://msdn.microsoft.com/en-us/library/cb20e19t.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/aa288457(v=vs.71).aspx [ ^ ]



2.创建第二个应用程序并使用System.Diagnostics.Process和ProcessStartInfo,您可以通过提供参数执行以前的exe文件,并且您还可以读取StandardOutput作为结果的过程。检查

http: //msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput(v=vs.110).aspx [ ^ ]

http://***.com/questions/4291912/process-start-how-to -get-the-output [ ^ ]
There may be many other ways to do this task, below is one way you can try this:

1. create command line exe which accept argument as number then you can calculate Factorial for that input and return the result. check below references
http://www.dotnetperls.com/main[^]
http://msdn.microsoft.com/en-us/library/cb20e19t.aspx[^]
http://msdn.microsoft.com/en-us/library/aa288457(v=vs.71).aspx[^]

2. Create 2nd application and using System.Diagnostics.Process and ProcessStartInfo you can execute previous exe file by providing argument and also you will able to read StandardOutput of the process as the result. check
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput(v=vs.110).aspx[^]
http://***.com/questions/4291912/process-start-how-to-get-the-output[^]