在 C#或 VB.Net 中,有一种方法可以将HttpWebResponse
对象翻译为HttpResponse
,或者直接获得HttpResponse
来自HttpWebRequest
实例的{1}}
我尝试做的例子(它不起作用):
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url2), HttpWebRequest)
Dim repsonse As HttpResponse = request.GetResponse()
答案 0 :(得分:1)
我相信你试图做这样的事情:
var request = WebRequest.Create(collection) as HttpWebRequest;
if (request != null)
using (var stream = request.GetResponse().GetResponseStream())
using (var writer = File.Create(path))
stream.CopyTo(writer);
这将采用HttpWebRequest
,然后它将构建Stream
,并将Stream
复制到FileStream
以写出内容。那是你的意思吗?