将带有32个条目的byte []保存到Metro Style App中的localSettings

时间:2012-09-09 18:22:12

标签: c# windows-8 microsoft-metro bytearray

我想将一个包含32个条目的bytearray(它的一个decryptedpassword)保存到localsettings。我没有错误,但是当我读到它时,我只得到一个包含18个条目的bytearray !!

为什么?

1 个答案:

答案 0 :(得分:1)

你正在“按原样”存储字节数组;但是你在使用它时使用UTF8对它进行编码,而不是你想要的。

这应该更好用;

byte[] passbyte = new byte[32];

// Store
localSettings.Values["password"] = passbyte;

// Fetch
var passwordsecure = localSettings.Values["password"] as byte[];