Search code examples
c#.netstringhttpwebresponse

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?


Solution

  • You should create a StreamReader around the stream, then call ReadToEnd.

    You should consider calling WebClient.DownloadString instead.