Download Manager/Class Object
Single to Multi-File Download Manager/Object/Class.
Written in C# or VB .NET
.Net Framework 3.5
Functionality is as follows:
Class will be instantiated. And will be able to support from a single download, to multiple concurrent downloads.
DownloadPath Path to where downloads get stored/saved
MaxDownloads Maximum Concurrent Downloads
ActiveDownloads List of DownloadObject Class
CompletedDownloads List of DownloadObject Class
WaitingDownloads List of DownloadObject class
Download_Started Pass DownloadObject Class of item to which started
Download_Completed Pass DownloadObject Class of item that completed
Add_Downloal (url of Download) return GUID ID of DownloadObject created
Cancel_Download (GUIDID as string) return boolean (true if cancelled, false if not waiting or active)
ID [url removed, login to view]
Url Url of file
SaveName Download Path + filename
Errored Boolean - if Download Errored
Error [url removed, login to view]
Cancelled Boolean - if Download was user Cancelled
Length Length of File
Bytes Current Byte count downloaded
TimeToCompletion Timespan - Computed time left to complete
Success Boolean - true if completed successfully/false if cancelled or failed
Tail Boolean - Last 10% retrieved
When a download begins, you must first execute a HEAD request to get the filesize, and then proceed to create the file on disk. (SetLength) Then two downloads start. 1. This is key, the last 10% of the file must be retrieved, and 2. From the beginning to the end-10%. The TAIL (end) download will complete much faster of course than part 2.
hey must be run concurrently. When the TAIL has been retrieved you update the DownloadObjectClass to true.
This must work this way, if NO LENGTH is returned in the HEAD REQUEST, you must start downloading from the beginning and look at the header on the GET to see if its there, as not all servers honor the HEAD request. Then execute the TAIL download. (eg 1,000,000 byte file, you download from the beginning 0-900,000, and at the same time download 900,001-1,000,000)
As information is retrieved or known, the DownloadObject Class must be updated. As data is retrieved, the Bytes counter must be updated. The TimeToCompletion must computed within the property GET based on the starttime, bytes retrieved.
The 3 lists, Active, Completed, Waiting must be SYNC locked when manipulating an ADD or REMOVE.
Good documented code. Use of an [url removed, login to view] is the preferred method for downloading the data. As we have code to throttle streams we can wrap in.
Files must be open in SHARED mode, as we will access them as the file is download as well.
See attached document for better formatting