我正在編寫使用Microsoft Visual Studio 2008的移動應用程序並需要加密文件。我試圖用一個File.Encrypt
方法,但它導致了以下錯誤:錯誤CS0117:'System.IO.File'不包含'Encrypt'的定義
error CS0117: 'System.IO.File' does not contain a definition for 'Encrypt'.
我怎樣才能解決這個問題?
我正在編寫使用Microsoft Visual Studio 2008的移動應用程序並需要加密文件。我試圖用一個File.Encrypt
方法,但它導致了以下錯誤:錯誤CS0117:'System.IO.File'不包含'Encrypt'的定義
error CS0117: 'System.IO.File' does not contain a definition for 'Encrypt'.
我怎樣才能解決這個問題?
它不起作用的原因是因爲File.Encrypt
實際上調用了本機Win32函數EncryptFile(LPSTR path)
,這將不會出現在移動設備上。
作爲替代方案,我的建議是使用System.Security.Cryptography
命名空間中的加密算法。
File.Encrypt
在移動.NET運行時中不存在。
嘗試使用ProtectedData
class。
感謝您的回覆。我試圖使用該類的Protect方法。我從鏈接中讀取了一個示例,並添加了System.Security.Cryptography,但該方法無法訪問 – user1943946
你可以發佈你的代碼嗎?我假設你試圖使用這個['File.Encrypt()'](http://msdn.microsoft.com/en-us/library/system.io.file.encrypt%28v=vs.90%29的.aspx)。 – Bobson