我的代码存在类型转换错误
int imglength = FileUpload2.PostedFile.ContentLength;
byte imgarray=new byte[imglength];
您正在尝试将一个字节数组 (byte[]
) 赋值给单个字节,因此出现错误。
请尝试以下代码:
byte[] imgarray = new byte[imglength];
你不能将一个字节数组分配给一个字节
尝试这样做
byte[] bytearray = new byte[imglength];
byte[] Buffer = new byte[imglength];
int imageSize = fuImage.PostedFile.ContentLength;
System.IO.Stream imageStream = fuImage.PostedFile.InputStream;
byte[] imageContent = new byte[imageSize];
int status = imageStream.Read(imageContent, 0, imageSize);
请检查:
int imgLength = FileUpload2.PostedFile.ContentLength;
byte[] revLength= BitConverter.GetBytes(imgLength);
Array.Reverse(revLength);
byte[] imgLengthB = revLength;
{}
)进行格式化和语法突出显示! - marc_s
byte[] imgarray = new byte[imglength];
- Tim