0

ファイルを復号化するとエラーが発生します。「道は法的な形式ではない」

たとえば、string privateKeyLocation = @"c:\privatekey.txt" など、privateKeyLocation を手動で指定すると、問題なく動作します。

しかし、ファイルを開くダイアログを使用して自分でキーファイルを見つけたいです。誰が何がうまくいかなかったのか知っていますか?前もって感謝します!

private void decryptFileButton_Click(object sender, EventArgs e)
        {
            string inputFileLocation = attachmentTextBox.Text;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.RestoreDirectory = true;
            string privateKeyLocation = new FileInfo(openFileDialog1.FileName).ToString();
            string privateKeyPassword = passphrase2TextBox.Text;
            string outputFile = @"c:\Original.txt";

            // decrypt and obtain the original file name
            // of the decrypted file
            string originalFileName =
                        pgp.DecryptFile(inputFileLocation,
                                    privateKeyLocation,
                                    privateKeyPassword,
                                    outputFile);
        }
4

1 に答える 1

2

showdialog() とその結果の単純な問題:

        private void decryptFileButton_Click(object sender, EventArgs e)
        {
            string inputFileLocation = attachmentTextBox.Text;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.RestoreDirectory = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string privateKeyLocation = new FileInfo(openFileDialog1.FileName).ToString();
                string privateKeyPassword = passphrase2TextBox.Text;
                string outputFile = @"c:\Original.txt";

                 decrypt and obtain the original file name
                 of the decrypted file
                string originalFileName =
                            pgp.DecryptFile(inputFileLocation,
                                        privateKeyLocation,
                                        privateKeyPassword,
                                        outputFile);
            }
        }
于 2013-10-30T01:46:39.607 に答える