C# 从网上下载文件
有没有办法让以下功能通过代理工作?
public T[] ReadStream(System.IO.TextReader reader);
我希望能够代理 reader
实例,以便它可以从网络读取尝试并将其缓存在某处。
或者也许为此目的有一些默认设置?
Is there a way to make the following function work via proxy?
public T[] ReadStream(System.IO.TextReader reader);
I want to be able to proxify the reader
instance, so that it could download a file from the web on reading attempts and cache it somewhere.
Or maybe there is something default for this purpose?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 WebClient.DownloadFile。如果需要代理,可以设置 WebClient 对象的 Proxy 属性。
这是一个示例:
您还可以使用 BinaryReader 分段下载文件:
Use WebClient.DownloadFile. If you need a proxy, you can set the Proxy property of your WebClient object.
Here's an example:
You can also download the file by parts with a BinaryReader:
也许这就是你想要的?鉴于您对前一个答案的评论,我对问题的措辞也有点困惑。
Perhaps this is what you want? I am also slightly confused by the wording of the question, given your comments to the previous answer.