如何转换WebResponse.GetResponseStream回报为一个字符串?

编程入门 行业动态 更新时间:2024-10-25 22:26:05
本文介绍了如何转换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回报为一个字符串?

本文发布于:2023-11-10 03:03:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574171.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   WebResponse   GetResponseStream

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!