YoItsTrev
✅ C# noob needs help retrying WebClient .DownloadString
I am a C# noob, so bear that in mind. I am trying to write a downloads a website sourcecode using WebClient .DownloadString. 95% of the time, it succeeds. But on occassion, it fails, and crashes the program. I have tried just about anything I could think of to try and get it to redownload the site source code anything it fails... This is the source I have currently:
static string getPageSource(string url)
{
string pageSource = "";
WebClient client = new WebClient();
pageSource = client.DownloadString(url); if(pageSource.Length == 0) { pageSource = client.DownloadString(url); } return pageSource; }
pageSource = client.DownloadString(url); if(pageSource.Length == 0) { pageSource = client.DownloadString(url); } return pageSource; }
83 replies