Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 303
nsantorello Avatar asked Aug 14 '09 17:08

nsantorello


1 Answers

byte[] response = new System.Net.WebClient().DownloadData(url);
like image 173
mmx Avatar answered Sep 22 '22 18:09

mmx