duankanyi6539 2011-08-31 13:29
浏览 142
已采纳

c#console应用程序与PHP页面交互

I have a c# console application that I invoke with a server call in PHP

chdir($filePath);
exec($filePath.$fileName);

This works great, the application is run. The data it is designed to collect is collected and everyone is happy. Currently I have plans on storing the one time use information on a server or a flat file, but then I noticed that while the console application is running and doing it's magic the page hangs waiting for the application to stop. This intrigued me, and now i'm wondering if there is a way for the application to pass it's data back to the page directly?

Note: I'm running Apache2 on Windows 7


Update:

Ended up using

$runCommand = "D:\\ScanBoyConsole\\ScanBoy_Console.exe COM1 9600 8 1 0 1"; 
$WshShell = new COM("WScript.Shell");
$output = $WshShell->Exec($runCommand)->StdOut->ReadAll;
json_decode($output);
  • 写回答

2条回答 默认 最新

  • dtgvl48608 2011-08-31 13:39
    关注

    If you mean by "directly" that you want the application's output sent to the client while it's still running you might be interested in passthru().
    If you're also the author of the C# application you could skip the console application and expose the functionality in a way accessible via php's COM and .Net module.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料