I'm trying to download files from a remote location. But right before the download, I get my file locations from a web service, also on a remote location.
The thing is, I get a degrading performance over time. The downloaded file numbers decrease from around 2k in 3 minutes to 300-400 in the same time after an hour or two and I have 250k files.
Is the service or the download a problem? Or both?
I download files as below after I get the names from the service,
try
{
using (WebClient client = new WebClient())
{
if (File.Exists(filePath + "/" + fileName + "." + ext))
{
return "File Exists: " + filePath + "/" + fileName + "." + ext;
}
client.DownloadFile(virtualPath, filePath + "/" + fileName + "." + ext);
return "Downloaded: " + filePath + "/" + fileName + "." + ext;
}
}
catch (Exception e) {
return"Problem Downloading " + fileName + ": " + e.Message;
}
The problem was the information put on the richTextBox and label.
The rtb was appended with info regarding whatever happened to each individual element. The Label showed at which element we were. Apparently the cpu can't handle it and this becomes a major problem when running for prolonged time. It ate so much cpu that it eventually killed the application. Removing or limiting their output solved almost all problems.
On the other hand, the slight degradation (1.5k to 1.2k per minute after 2.5 hours) of the download that still exists is still a mystery.