I need to download a huge number of files from net based on a keyword. The steps i am following are
- Using Scraping figure out the links to files
- Using WebClient.DownloadData() download the byte[]
- Save the arr to a file.
Is it a good idea to create one thread for downloading each file for better performance. Any suggestions. Thanks
foreach (string each in arr)
{
Thread t = new Thread(
new ThreadStart(
delegate
{
string[] arr2 = each.Split(new string[] { "http://" }, StringSplitOptions.None);
string[] firstElem = arr2[1].Split(new string[] { " " }, StringSplitOptions.None);
string urlToDownload = @firstElem[0].Replace("\"", string.Empty);
string filName = Path.GetFileName(urlToDownload);
string dirName = DirInAppConfig();
DataRow row;
bool dataExistsInDtKwWithSameDownloadLinkAndFileName;
getRowForKwDownLinkFileName(urlToDownload, filName, out row, out dataExistsInDtKwWithSameDownloadLinkAndFileName);
downloadFile(Client, urlToDownload, dirName, filName, search, row);
}));
t.IsBackground = true;
t.Start();
t.Join();
}