我有一个 byte[] 类型的属性
byte[] _signature;
public byte[] Signature
{
get { return _signature; }
set
{
if (_signature != value)
{
_signature = value;
base.RaisePropertyChanged("Signature");
}
}
}
将值设置为此
System.Drawing.Image img = System.Drawing.Image.FromFile(openfile.FileName);
//covert image to base64 and save to sign
SignaturePath = openfile.FileName;
Signature = ImageTobyte(img, img.RawFormat);
....
private byte[] ImageTobyte(System.Drawing.Image image, ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
return imageBytes;
}
}
我收到错误Signature = ImageTobyte(img, img.RawFormat);
:无法将“System.Byte []”类型的对象转换为“System.String”类型。