【发布时间】:2013-06-25 14:48:56
【问题描述】:
所以目前我在 Visual Studio 中有一个 C#/ASP.net 应用程序。我还有一个由其他人编写的 perl 脚本,我必须在我的 C#/ASP.NET 应用程序中使用它。最终目标是将我的 C#/ASP.NET 代码中生成的字符串传递到这个 perl 脚本(该字符串是一个文件路径),以便 perl 脚本运行并给出适当的输出。
我翻遍了,只找到了这个例子:
ProcessStartInfo perlStartInfo = new ProcessStartInfo(@"d:\Perl\bin\perl.exe");
perlStartInfo.Arguments = "c:\\word-splitter.pl " + "c:\\a.txt" + " ispell";
perlStartInfo.UseShellExecute = false;
perlStartInfo.RedirectStandardOutput = true;
perlStartInfo.RedirectStandardError = true;
perlStartInfo.CreateNoWindow = false;
Process perl = new Process();
perl.StartInfo = perlStartInfo;
perl.Start();
perl.WaitForExit();
string output = perl.StandardOutput.ReadToEnd();
问题在于,每当我将此代码放入 Visual Studio 时,它都无法识别 ProcessStartInfo 或此代码块使用的任何其他命名空间。我错过了一个程序集吗?...这个块到底是做什么的?我尝试搜索 Nuget 包和程序集,但只发现 PCRE(Perl 兼容正则表达式)无法安装,因为它与 .NetFramwork V4.5 不兼容。
所以我的问题是:在 C#/ASP.NET 应用程序中运行 perl 脚本的协议是什么?
谢谢。
【问题讨论】:
-
澄清一下,你已经加入了
using System.Diagnostics,对吧? -
我刚刚添加了它。现在可以识别名称空间。但是,我仍然不清楚从这里去哪里。感谢您的帮助!
-
查看 MSDN 了解您正在使用的课程 - 有很多信息。在 SO/everywhere 上搜索类似问题...当您通过“请解释
Process.Start的工作原理”时更新问题,使其成为适合 SO 的具体问题。 (投票暂时关闭)
标签: c# asp.net perl visual-studio-2012