gpt4 book ai didi

c# - 将对象转换为 byte[]

转载 作者:太空宇宙 更新时间:2023-11-03 17:22:28 24 4
gpt4 key购买 nike

我正在尝试将检索到的注册表值从 object 转换为 byte[]。它存储为 REG_BINARY。我尝试将 BinaryFormatterMemoryStream 一起使用。但是,它添加了我不想要的开销信息。当我随后通过执行函数 Convert.ToBase64String(..) 将字节数组转换为字符串时,我观察到了这一点。我正在执行这些功能,因为我正在测试注册表中加密 key 的存储和检索。

最佳答案

如果它是一个 REG_BINARY 那么当你检索它时它应该已经 一个字节数组...你不能将它转换为 byte[] 吗?

或者,如果您还没有验证它在代码中是 REG_BINARY,您可能想要使用:

byte[] binaryData = value as byte[];
if (binaryData == null)
{
// Handle case where value wasn't found, or wasn't binary data
}
else
{
// Use binaryData here
}

关于c# - 将对象转换为 byte[],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4684816/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com