Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert WebResponse.GetResponseStream return into a string?

I see many examples but all of them read them into byte arrays or 256 chars at a time, slowly. Why?

Is it not advisable to just convert the resulting Stream value into a string where I can parse it?

like image 815
Joan Venge Avatar asked Sep 25 '11 02:09

Joan Venge


1 Answers

You can use StreamReader.ReadToEnd(),

using (Stream stream = response.GetResponseStream()) {    StreamReader reader = new StreamReader(stream, Encoding.UTF8);    String responseString = reader.ReadToEnd(); } 
like image 178
KV Prajapati Avatar answered Sep 21 '22 11:09

KV Prajapati