我需要通过 GnuPG 加密来加密文件的内容。为此,我从 FILE 中获取内容并通过 StandardInput 传递它。对于小数据,它工作正常,但是当我尝试写入超过 500KB 数据的 StandardInput 时,程序卡住了。
process = new Process();
process.StartInfo.WorkingDirectory = _bindirectory;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.FileName = gpgExecutable;
process.StartInfo.Arguments = gpgOptions;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
/*****Here is the line where Compiler Process Stucks on large data****/
process.StandardInput.Write(inputText);
process.StandardInput.Flush();
process.StandardInput.Close();
process.OutputDataReceived += process_OutputDataReceived;
process.ErrorDataReceived += process_ErrorDataReceived;
process.BeginErrorReadLine();
process.BeginOutputReadLine();
process.WaitForExit();
请提出解决方案?我应该分块发送文件数据吗???