1
我对C#非常陌生,因为我需要为我的老板制作一个简单的项目。从C#中的OpenFileDialog中选定的文件运行CMD命令
正是我想要得到的是:
- 获取选定的文件由用户(打开文件对话框)解密。
- 获取用户选定的文件用作密钥。
- 运行CMD与功能的OpenSSL ENC -d -AES-256-CBC -in userSelectedFilesToDecrypt .enc退房手续UserSelectedFilesAlreadyDecrypted .MP3文件-pass:./ user_selected_key_file的.bin
就这样。
我已经有了:
- 打开文件对话框让用户在两个选项(1和2)
我需要使用:
- 代码输入/输出。
这里是我当前的代码:
{
Process decrypt = new Process();
string processExecutable = @"C:\Windows\System32\cmd.exe";
if (!File.Exists(processExecutable))
throw new ApplicationException(string.Format("The executable file \"{0}\" does not exist.", processExecutable));
decrypt.StartInfo.FileName = processExecutable;
decrypt.StartInfo.Arguments = "/C openssl enc -d -aes-256-cbc -in FILES_IN.enc -out FILES_OUT.mp3 -pass file:./KEY_FILE.bin";
decrypt.StartInfo.UseShellExecute = false;
decrypt.StartInfo.RedirectStandardOutput = true;
decrypt.StartInfo.RedirectStandardError = true;
decrypt.StartInfo.RedirectStandardInput = true;
decrypt.StartInfo.CreateNoWindow = true;
decrypt.Start();
decrypt.BeginOutputReadLine();
decrypt.BeginErrorReadLine();
decrypt.WaitForExit();
decrypt.Close();
}
我应该如何修改它,才能够使用这个由用户选择的文件吗?感谢您的任何帮助。
是的,如果您可以测试它会很好,因为我仍然遇到问题。 –
我会在下班后尝试写一个示例应用程序,我不介意等待 –
当然没有。感谢您花时间帮助别人。 –