[英]Cannot implicitly convert 'byte[]' to 'byte'
My given code has an error of type conversion 我给定的代码有类型转换错误
int imglength = FileUpload2.PostedFile.ContentLength;
byte imgarray=new byte[imglength];
You're trying to assign an array of bytes ( byte[]
) to a single byte, hence the error. 您尝试将字节数组(
byte[]
)分配给单个字节,因此会出现错误。
Try the following code: 尝试以下代码:
byte[] imgarray = new byte[imglength];
you can not assign a byte array to byte 您不能将字节数组分配给byte
try this 尝试这个
byte[] bytearray = new byte[imglength];
结构是这样的
byte[] Buffer = new byte[imglength];
You can use the below code: 您可以使用以下代码:
int imageSize = fuImage.PostedFile.ContentLength;
System.IO.Stream imageStream = fuImage.PostedFile.InputStream;
byte[] imageContent = new byte[imageSize];
int status = imageStream.Read(imageContent, 0, imageSize);
This code coverts postedfile to byte stream 此代码将发布文件转换为字节流
Check this: 检查一下:
int imgLength = FileUpload2.PostedFile.ContentLength;
byte[] revLength= BitConverter.GetBytes(imgLength);
Array.Reverse(revLength);
byte[] imgLengthB = revLength;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.