Download a file over HTTP into a byte array in C#?

2019-01-18 09:08发布

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.

1条回答
仙女界的扛把子
2楼-- · 2019-01-18 09:44
byte[] response = new System.Net.WebClient().DownloadData(url);
查看更多
登录 后发表回答