gpg(GnuPG) を使用して .csv ファイルを .gpg ファイルに暗号化しています。以下のコードは、デバッグ モードで暗号化されたファイルを生成します。Windows サービスの下にインストールすると、例外がスローされます。「gpg: <>C:\emp.csv: スキップ: 公開鍵がありません gpg: [stdin]: 暗号化に失敗しました: 公開鍵がありません」. 「consoleapp.exe -c」のようなデバッグ モードでサービスを実行すると機能します</p>
string arguments = string.Format(" --yes --quiet --always-trust -e -o {0} -r \"{1}\" {2}", "C:\\emp.gpg", "KeyName", "C:\\emp.csv");
ProcessStartInfo pInfo = new ProcessStartInfo( @"C:\Program Files (x86)\GNU\GnuPG\gpg2", arguments );
pInfo.WorkingDirectory = @"C:\Program Files (x86)\GNU\GnuPG\";
pInfo.CreateNoWindow = false;
pInfo.UseShellExecute = false;
pInfo.RedirectStandardInput = true;
pInfo.RedirectStandardOutput = true;
pInfo.RedirectStandardError = true;
Process process = new Process()
{
StartInfo = pInfo,
EnableRaisingEvents = true
};
process.Start();
error = process.StandardError.ReadToEnd();
agent.LogConsole(process.StandardOutput.ReadToEnd());