2011-02-23 82 views
0

我的一位朋友在工作中找到我,问他为什么不能正确运行该代码。C#和OpenSSL可执行文件

using System.Diagnostics; 

namespace ConsoleApplication1 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      ProcessStartInfo startInfo = new ProcessStartInfo(); 
      string processExecutable = "C:\\OpenSSL-Win32\\bin\\openssl.exe"; 

      startInfo.FileName = processExecutable; 
      startInfo.Arguments = @"genrsa -out Prvkey.key"; 

      startInfo.UseShellExecute = false; 
      startInfo.RedirectStandardOutput = true; 
      startInfo.RedirectStandardError = true; 
      startInfo.RedirectStandardInput = true; 
      startInfo.CreateNoWindow = true; 

      Process.Start(startInfo); 
     } 
    } 
} 

,当他使用openSSL.exe,定期,单击.exe文件,并把指令“genrsa -out Prvkey.key”,它工作正常。所以它不是说明本身,而是如何通过。 任何想法?

+0

什么问题? – alexl 2011-02-23 15:04:12

回答

1

这对我工作得很好:

ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\OpenSSL-Win32\bin\openssl.exe", "genrsa -out Prvkey.key"); 
    Process.Start(startInfo);