I am downloading a file from a website and I have the link. But the end part of the link changes to the current month. I need to loop through the link, making changes to the month part of it, and download the file.
My first question is how to know if a link has failed, to go to another link? Second ,can you can suggest me a way to loop through the link?
Initially I provide the link in a textbox.
Here is the current code
if (textBox2.Text != "")
{
System.Net.WebClient we = new System.Net.WebClient();
we.DownloadFile(textBox2.Text, "c:\\NPPES.zip");
//this is the link //"http://nppesdata.cms.hhs.gov/NPPES_Data_Dissemination_July_2009.zip","c:\\NPPES.zip");
//string file = "C:\\NPPES.csv";
Unzipfile("c:\\NPPES.zip", "c:\\NPPES.csv");
MessageBox.Show("Download complete.Select the file to Import data");
}