c#中作为服务编译的gpg命令行不起作用

c#中作为服务编译的gpg命令行不起作用,c#,gnupg,C#,Gnupg,编码是在C#中,使用Visual Studio 2019。如果我用copy命令替换scommandline,整个过程都会工作…那么gpg命令不工作吗?如果我将其粘贴到命令提示符中,它就会工作。 希望sm1能帮上忙 System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe") { CreateNoWindow = true, UseShellExecute = fa

编码是在C#中,使用Visual Studio 2019。如果我用copy命令替换scommandline,整个过程都会工作…那么gpg命令不工作吗?如果我将其粘贴到命令提示符中,它就会工作。 希望sm1能帮上忙

System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe")
{
    CreateNoWindow = true,
    UseShellExecute = false,
    RedirectStandardInput = true,
    RedirectStandardOutput = true,
    RedirectStandardError = true
};
System.Diagnostics.Process process = Process.Start(startInfo);

string sCommandLine = @"gpg --batch --pinentry-mode loopback --passphrase ******************** -- 
  output D:\extract_CES_SAE_v3_p0002031crfc_20201008205801.txt --decrypt 
    D:\extract_CES_SAE_v3_p0002031crfc_20201008205801.txt.pgp" ;

try
{
     process.StandardInput.WriteLine(sCommandLine);
     process.StandardInput.Flush();
     process.StandardInput.Close();
     process.WaitForExit();
     process.Close();
}

执行代码时,您得到的输出是什么?另外,
StandardError
中的内容是什么,您有任何输出吗?没有错误…当我将项目创建为windows应用程序并执行时…所有工作正常…因此您不会从
StandardOutput
StandardError
中获得任何输出?没有…因此,首先,我测试了cmd.exe是否有效…因此发送了一个简单的副本文件作为请求,并且有效。由于您有一个
try
块,您在
catch
块中做什么?您是否收到任何异常?如果是,异常消息是什么?