- Thread starter
- #11
ok...thanks 
I hope you are talking about OLD code. New code is very simple and really functional. I prefer to talk about the new code and possible improvements.Looking at the DownLoadImage code it is really a mess, I'm pretty sure there is a way more simple way to do what the current code does.
I hope you are talking about OLD code. New code is very simple and really functional. I prefer to talk about the new code and possible improvements.Looking at the DownLoadImage code it is really a mess, I'm pretty sure there is a way more simple way to do what the current code does.![]()
Unfortunately both old and proposed version are way too complex and low-level. You can do exactly same by using WebClient.DownloadFile and setting the correct headers. If
Some common headers are considered restricted and are protected by the system and cannot be set or changed in a WebHeaderCollection object. Any attempt to set one of these restricted headers in the WebHeaderCollection object associated with a WebClient object will throw an exception later when attempting to send the WebClient request.
Restricted headers protected by the system include, but are not limited to the following:
Date
Host
In addition, some other headers are also restricted when using a WebClient object. These restricted headers include, but are not limited to the following:
Accept
..
This post is not about Syn or AsyncIf you want to do it asynchronously you can say ThreadPool.QueueUserWorkItem(o => Download(file)).
So, you can't use Header Accept
using (Stream input = request.GetResponse().GetResponseStream())
{
using (Stream output = new FileStream(strFile, FileMode.OpenOrCreate, FileAccess.Write))
{
input.CopyTo(output);
}
}
if (foo)
{
..code..
}
Really, i don't want to start in Media Portal in the wrong way or defend the indefensible. But i think my code is OK (except maybe Sleep)
Hi seco (and all). Thx for your comments.. I will rewrite the code with {}. But Sleep, what about Sleep and Catch?