通过HTTP下载文件到C#中的字节数组? [英] Download a file over HTTP into a byte array in C#?
本文介绍了通过HTTP下载文件到C#中的字节数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要看书,我有一个网址为一个字节数组的文件。我一直在使用 File.ReadAllBytes
本地阅读文件,我一直无法弄清楚,以在网络上的一个文件最彻底的方法。
我想这是code的只是一个快速的片段,但一切我可以通过搜索找到只对本地文件。
谢谢!
解决方案
字节[] =响应新System.Net.WebClient()DownloadData(URL)。
I'm trying to read a file that I have a web address for into a byte array. I've been using File.ReadAllBytes
to read files locally and I've been unable to figure out the cleanest way to do this for a file on the web.
I imagine this is just a quick snippet of code, but everything I can find through search is only for local files.
Thanks!
解决方案
byte[] response = new System.Net.WebClient().DownloadData(url);
这篇关于通过HTTP下载文件到C#中的字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文