[英]How do I write a byteArray to a specific path
I currently have a method which is taking a picture and saving it.. Once saved I call this method to encrypt the file from a string path but im not sure how to save it.. I wanted to do 我目前有一种拍照并保存它的方法。保存后,我调用此方法从字符串路径加密文件,但是我不确定如何保存它。
string path = @"C:/somePath"
File.WriteAllBytes(path); File.WriteAllBytes(path);
but that doesnt work obv. 但这不起作用。 So how do I properly save a bytearray?
那么如何正确保存字节数组?
string key = GetUniqueKey(32);
byte[] encKey = Encoding.UTF8.GetBytes(key);
byte[] imgBytes = File.ReadAllBytes(path);
byte[] ebytes = encrypt.AESEncrypt(imgBytes, encKey);
File.WriteAllBytes();
If you actually check the parameters it's asking for, you need to provide the bytes as well as the path. 如果您实际上检查了它所要求的参数,则需要提供字节和路径。
So: 所以:
string path = @"C:/somePath/somefile.png"
string key = GetUniqueKey(32);
byte[] encKey = Encoding.UTF8.GetBytes(key);
byte[] imgBytes = File.ReadAllBytes(path);
byte[] ebytes = encrypt.AESEncrypt(imgBytes, encKey);
File.WriteAllBytes(path, ebytes);
方法的签名是:
File.WriteAllBytes(string path, byte[] bytes)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.