Yip*_*Yay 2 .net c# proxy download textreader
有没有办法通过代理使以下功能工作?
public T[] ReadStream(System.IO.TextReader reader);
我希望能够代理reader实例,以便它可以在读取尝试时从Web下载文件并将其缓存到某处.
或者为此可能有默认值?
使用WebClient.DownloadFile.如果需要代理,可以设置WebClient对象的Proxy属性.
这是一个例子:
using (var client = new WebClient())
{
    client.Proxy = new WebProxy("some.proxy.com", 8000);
    client.DownloadFile("example.com/file.jpg", "file.jpg");
}
您还可以使用BinaryReader按部件下载文件:
using (var client = new WebClient())
{
    client.Proxy = new WebProxy("some.proxy.com", 8000);
    using (var reader = new BinaryReader(client.OpenRead("example.com/file.jpg")))
    {
        reader.ReadByte();
        reader.ReadInt32();
        reader.ReadBoolean();
        // etc.
    }
}
| 归档时间: | 
 | 
| 查看次数: | 4047 次 | 
| 最近记录: |