0
我有类型字节的属性[]无法转换类型的对象 'System.Byte []' 为类型 'System.String'
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'。
调试器不会告诉你哪个行发生异常吗? – mostruash
Signature = ImageTobyte(img,img.RawFormat); –
一切都在这里。如果签名是byte [],它必须工作。 –