0

私の問題は、コマンド ラインを実行しても、復号化テキスト ファイルに何も追加されないことです。私は、decrypt.txt ファイルにテキストを追加して、書き込みがあるかどうかを確認しました。

        System.Diagnostics.ProcessStartInfo psi =
        new System.Diagnostics.ProcessStartInfo("cmd.exe");
        psi.CreateNoWindow = true;
        psi.UseShellExecute = false;
        psi.RedirectStandardInput = true;
        psi.RedirectStandardOutput = true;
        psi.RedirectStandardError = true;
        psi.WorkingDirectory = "c:\\";

        System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
        string sCommandLine = "echo femme toxin sorghum| gpg.exe --batch --passphrase-fd 0 --decrypt E:\\entemp.txt > E:\\detemp.txt";
        process.StandardInput.WriteLine(sCommandLine);
        process.StandardInput.Flush();
        process.StandardInput.Close();
        process.WaitForExit();
        process.Close();
4

1 に答える 1

2

私は最近、多くの gpg.exe を行っています...

gpgコマンド標準をファイルにリダイレクトしていると思います...

あなたはこのようなものがもっと欲しいかもしれません

echo password123|gpg.exe --yes --batch --passphrase-fd 0 --decrypt --output c:\file.txt c:\file.gpg

cmd を呼び出してからコマンドを渡す代わりに、プロセス内で gpg.exe を直接呼び出すこともできます--yes ... c:\file.gpg。次に...最初の入力は次のようになりますgpgProc.standardinput.writeline(password123);

この方法では、標準エラー出力を取得し、cmd.exe 終了コードなどの代わりに gpg.exe の終了コードを直接処理することもできます。

おそらくそれが役立つでしょう...

于 2011-08-06T02:34:26.010 に答える