Link to home
Start Free TrialLog in
Avatar of Viraj_Kanwade
Viraj_KanwadeFlag for India

asked on

need help converting stream to byte array.

Stream ReceiveStream = myWebResponse.GetResponseStream();

i am using this stream and need to convert it to a byte array. i have to pass the byte array to another function ao i need the stream converted whole to byte array and the size of data received in stream is variable.
so can any1 please give me a code to convert this.
Avatar of wishguitar
wishguitar

MemoryStream ReceiveStream = (MemoryStream)myWebResponse.GetResponseStream();
Byte [] bytes = ReceiveStream.ToArray();
Avatar of Viraj_Kanwade

ASKER

MemoryStream ReceiveStream = (MemoryStream)myWebResponse.GetResponseStream();

on this i get a >> specified cast is not valid << exception
is there any other way or some changes needed to the above code
ASKER CERTIFIED SOLUTION
Avatar of Ceiled
Ceiled
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial