2014-01-28 4 views
3

내 주어진 코드는 따라서 단일 바이트 바이트의 배열 (byte[])을 할당하려는암시 적으로 변환 할 수 없습니다 '바이트 []'

int imglength = FileUpload2.PostedFile.ContentLength; 
byte imgarray=new byte[imglength]; 
+5

는'byte'가'바이트 [] '과 같은 것은 아니다. 첫 번째 바이트는 바이트이고 두 번째 바이트는 바이트 배열입니다. 'byte [] imgarray = new byte [imglength];' – Tim

답변

5

타입 변환의 오류가 '바이트'에 오류.

다음 코드를보십시오 :

byte[] imgarray = new byte[imglength]; 
1

구조는이

byte[] bytearray = new byte[imglength]; 
3

같다 아래 코드를 사용할 수 있습니다. :

int imageSize = fuImage.PostedFile.ContentLength; 
System.IO.Stream imageStream = fuImage.PostedFile.InputStream; 
byte[] imageContent = new byte[imageSize]; 
int status = imageStream.Read(imageContent, 0, imageSize); 

깃이

+0

선생님도 노력하고 있지만 작동하지 않습니다 – Raghu

1

당신을 시도

를 바이트 바이트 배열을 할당 할 수 없습니다이

byte[] Buffer = new byte[imglength]; 
0

확인 바이트 스트림에 postedfile이 코드이 :

int imgLength = FileUpload2.PostedFile.ContentLength; 
byte[] revLength= BitConverter.GetBytes(imgLength); 
Array.Reverse(revLength); 
byte[] imgLengthB = revLength; 
+4

코드, XML 또는 데이터 샘플을 게시하는 경우 ** 텍스트 편집기에서 해당 행을 강조 표시하고 클릭하십시오. 편집기 툴바의 "코드 샘플"버튼 ('{}')을 클릭하여 멋지게 포맷하고 구문을 강조 표시하십시오! –

관련 문제