README.md
December 4, 2022 ยท View on GitHub
Description
Downloads a URI directly into a string or a web binary to a byte array.
More Info
| Submitted On | |
| By | Jon Davis |
| Level | Beginner |
| User Rating | 4.5 (18 globes from 4 users) |
| Compatibility | C# |
| Category | Internet/ Browsers/ HTML |
| World | .Net (C#, VB.net) |
| Archive File |
Source Code
public static string StringFromURL(string URL) {
System.Net.WebClient WC = new System.Net.WebClient();
System.IO.StreamReader sr = new System.IO.StreamReader(StreamFromURL(URL));
return sr.ReadToEnd();
}
public static byte[] BinFromURL(string URL) {
System.IO.BinaryReader br = new System.IO.BinaryReader(StreamFromURL(URL));
return br.ReadBytes((int)br.BaseStream.Length);
}
public static System.IO.Stream StreamFromURL(string URL) {
System.Net.WebClient WC = new System.Net.WebClient();
return WC.OpenRead(URL);
}