如何转换WebResponse.GetResponseStream回报为一个字符串? [英] How to convert WebResponse.GetResponseStream return into a string?
本文介绍了如何转换WebResponse.GetResponseStream回报为一个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我看到很多例子,但所有的人都读成字节数组或256个字符的时间,慢慢的。为什么呢?
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?
推荐答案
您应该创建一个的StreamReader
绕流,然后调用 ReadToEnd
。
You should create a StreamReader
around the stream, then call ReadToEnd
.
您应该考虑调用 WebClient.DownloadString
代替。
这篇关于如何转换WebResponse.GetResponseStream回报为一个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文