C# PGP:解密空文件

C# PGP:解密空文件,c#,cmd,pgp,gnupg,C#,Cmd,Pgp,Gnupg,我正在尝试使用以下代码解密文件: Process process = Process.Start(psi); string command = @"echo " + password + "|gpg.exe --passphrase-fd 0 --batch --verbose --yes --output " + decryptedFilePath + @" --decrypt """ + encryptedFilePath; process.StandardInput.WriteLine(c

我正在尝试使用以下代码解密文件:

Process process = Process.Start(psi);
string command = @"echo " + password + "|gpg.exe --passphrase-fd 0 --batch --verbose --yes --output " + decryptedFilePath + @" --decrypt """ + encryptedFilePath;
process.StandardInput.WriteLine(command);
process.StandardInput.Flush();
process.StandardInput.Close();
process.WaitForExit();
在文件不为空之前,一切正常。 若文件不包含任何数据,PGP不会为我创建文件。 你知道有什么办法可以解决它吗

我知道,我可以这样检查长度:

if (new FileInfo(encryptedFilePath).Length == 0)

并复制具有不同扩展名的文件,但我希望有更优雅的解决方案,例如,命令的某些选项强制创建文件,即使文件是空的,或者类似的:)

如果文件长度为零或不存在,并且您希望输出文件为空,则不要将其传递给PGP,只需
file.CreateText(decryptedFilePath).Close()确定,但它仍然是通过.net库创建新文件的解决方案。这是否意味着没有通过PGP强制创建文件的选项?