Hi, I want to create my own multi-threading file downloader, and - as I am reading and alpha-testing some code examples, I've found a weird scenario - when I test the code below, I paste a download link that the server does not supports SeekOperations, so I must dowload the file in 1 thread. When I paste the same download link to e.g FlashGet, I see that the file is segmented and it's being downloaded by 8 threads at the same time. Why ?
int startPointInt = Convert.ToInt32(startPoint);
webRequest = (HttpWebRequest)WebRequest.Create(URLTextBox.Text);
webRequest.AddRange(100, 200);
webRequest.Credentials = CredentialCache.DefaultCredentials;
webResponse = (HttpWebResponse)webRequest.GetResponse();
Int64 fileSize = webResponse.ContentLength;
strResponse = webResponse.GetResponseStream();
if (startPointInt == 0)
strLocal = new FileStream(txtPath.Text, FileMode.Create, FileAccess.Write, FileShare.None);
else
strLocal = new FileStream(txtPath.Text, FileMode.Append, FileAccess.Write, FileShare.None);
int bytesSize = 0;
byte[] downBuffer = new byte[2048];
while ((bytesSize = strResponse.Read(downBuffer,0, downBuffer .Length)) > 0)
{
strLocal.Write(downBuffer, 0, bytesSize);
}