2013-10-30 81 views
0

任何人都知道如何將@"C:\Test\public_key.asc"從手動輸入更改爲使用openfiledialog?DIDISOFT PGP文件加密

我試圖做到這一點,在代碼下有這個紅色的zizag線,當我把鼠標放在上面時,它說它不能將System.IO.FileInfo轉換爲System.IO.Stream。

using System.IO; 
using DidiSoft.Pgp; 

class EncryptDemo { 
public void Demo() { 
    // create an instance of the library 
    PGPLib pgp = new PGPLib(); 

    // specify should the output be ASCII or binary 
    bool asciiArmor = false; 
    // should additional integrity information be added 
    // set to false for compatibility with older versions of PGP such as 6.5.8. 
    bool withIntegrityCheck = false; 

    pgp.EncryptFile(@"C:\Test\INPUT.txt", 
        @"C:\Test\public_key.asc", 
        @"C:\Test\OUTPUT.pgp", 
        asciiArmor, 
        withIntegrityCheck); 
} 
} 

以下對我們沒有幫助,因爲它沒有打開對話框讓我選擇我的文件。

bool asciiArmor = false; 
    bool withIntegrityCheck = false; 
    using (var publickey = new FileStream(openFileDialog1.FileName, FileMode.Open)) 
    { 
     pgp.EncryptFile(@attachmentTextBox.Text, publickey, @"C:\OUTPUT.pgp", asciiArmor, withIntegrityCheck); 
    } 

回答

1

你有沒有試着用:

bool asciiArmor = false; 
bool withIntegrityCheck = false; 
pgp.EncryptFile(@attachmentTextBox.Text, openFileDialog1.FileName, @"C:\OUTPUT.pgp", asciiArmor, withIntegrityCheck);