How could I use C# to download the contents of a URL, and store the text in a string, without having to save the file to the hard drive?
using System.IO;
using System.Net;
WebClient client = new WebClient();
string dnlad = client.DownloadString("http://www.stackoverflow.com/");
File.WriteAllText(@"c:\Users\Admin\Desktop\Data1.txt", dnlad);
got it from MVA hope it helps
Use a WebClient
var result = string.Empty;
using (var webClient = new System.Net.WebClient())
{
result = webClient.DownloadString("http://some.url");
}
See WebClient.DownloadString. Note there is also a WebClient.DownloadStringAsync method, if you need to do this without blocking the calling thread.
string contents;
using (var wc = new System.Net.WebClient())
contents = wc.DownloadString(url);
use this Code Simply
var r= string.Empty;
using (var web = new System.Net.WebClient())
r= web.DownloadString("http://TEST.COM");