c# - "This stream does not support seek operations" -



c# - "This stream does not support seek operations" -

i stream form web service:

stream resultstream = webserviceentities.getattachment(attachmentid);

i need convert stream byte array but

attempt # 1

byte[] resultbytes = null; using (stream stream = resultstream) { using (memorystream ms = new memorystream()) { int count = 0; { byte[] buf = new byte[1024]; count = stream.read(buf, 0, 1024); ms.write(buf, 0, count); } while (stream.canread && count > 0); resultbytes = ms.toarray(); } }

attempt # 2:

var memorystream = new memorystream(); resultstream.copyto(memorystream); byte[] resultbytes = memorystream.toarray();

in both cases (byte[] resultbytes) returns empty byte array, know causing happen? there wrong stream web service returns?

c# asp.net arrays stream byte

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -