0
我解密我的文件時出現錯誤。 「路徑不是合法形式」路徑不合法的形式錯誤openfiledialog
如果我手動指定privateKeyLocation,例如字符串privateKeyLocation = @「c:\ privatekey.txt」,它沒關係,運行良好。
但我想使用打開的文件對話框自己找到密鑰文件。 有人知道哪裏出了問題? 在此先感謝!
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);
}
什麼是一個值的例子'privateKeyLocation'你'的FileInfo()的ToString()'進去呢?另外,「打開」對話框是否正確顯示?你需要調用'openFileDialog1.ShowDialog()'? – cxw