C# Class Nexus.Client.Util.Downloader.FileDownloader

Downloads a file.
This downloader uses multiple connections to download the file. It also supports resuming interrupted downloads.
Mostra file Open project: NexusMods/NexusModManager-4.5 Class Usage Examples

Public Methods

Method Description
Cleanup ( ) : void

Cleans up the meta files used while downloading.

FileDownloader ( Uri p_uriURL, string>.Dictionary p_dicCookies, string p_strSavePath, bool p_booUseDefaultFileName, Int32 p_intMaxConnections, Int32 p_intMinBlockSize, string p_strUserAgent ) : System

A simple constructor that initializes the object with the given values.

If the given p_strSavePath already exists, an attempt will be made to resume the download. If the pre-existing file is not a partial download, or the download cannot be resumed, the file will be overwritten.

StartDownload ( ) : void

Starts the file download.

Stop ( ) : void

Stops the file download.

Protected Methods

Method Description
GetMetadata ( ) : FileMetadata

Gets the file's metadata.

GetNextBlock ( ) : Range

Gets the next block in the file that needs to be downloaded.

OnDownloadComplete ( CompletedDownloadEventArgs e ) : void

Raises the DownloadComplete event.

A completed download does not mean the entire file has been downloaded; the download may have been interrupted.

OnDownloadComplete ( bool p_booGotEntireFile, string p_strSavedFileName ) : void

Raises the DownloadComplete event.

A completed download does not mean the entire file has been downloaded; the download may have been interrupted.

Private Methods

Method Description
Downloader_FinishedDownloading ( object sender, EventArgs e ) : void

Handles the BlockDownloader.FinishedDownloading events of the BlockDownloaders being used.

This stops the file download once all the BlockDownloaders have finished.

Initialize ( string p_strSavePath, bool p_booUseDefaultFileName ) : void

Sets up the initial values of the downloader.

Method Details

Cleanup() public method

Cleans up the meta files used while downloading.
public Cleanup ( ) : void
return void

FileDownloader() public method

A simple constructor that initializes the object with the given values.
If the given p_strSavePath already exists, an attempt will be made to resume the download. If the pre-existing file is not a partial download, or the download cannot be resumed, the file will be overwritten.
public FileDownloader ( Uri p_uriURL, string>.Dictionary p_dicCookies, string p_strSavePath, bool p_booUseDefaultFileName, Int32 p_intMaxConnections, Int32 p_intMinBlockSize, string p_strUserAgent ) : System
p_uriURL System.Uri The URL of the file to download.
p_dicCookies string>.Dictionary A list of cookies that should be sent in the request to download the file.
p_strSavePath string The path to which to save the file. /// If is false, this value should be a complete /// path, including filename. If is true, /// this value should be the directory in which to save the file.
p_booUseDefaultFileName bool Whether to use the file name suggested by the server.
p_intMaxConnections System.Int32 The maximum number of connections to use to download the file.
p_intMinBlockSize System.Int32 The minimum block size that should be downloaded at once. This should /// ideally be some mulitple of the available bandwidth.
p_strUserAgent string The current User Agent.
return System

GetMetadata() protected method

Gets the file's metadata.
protected GetMetadata ( ) : FileMetadata
return FileMetadata

GetNextBlock() protected method

Gets the next block in the file that needs to be downloaded.
protected GetNextBlock ( ) : Range
return Range

OnDownloadComplete() protected method

Raises the DownloadComplete event.
A completed download does not mean the entire file has been downloaded; the download may have been interrupted.
protected OnDownloadComplete ( CompletedDownloadEventArgs e ) : void
e CompletedDownloadEventArgs A describing the event arguments.
return void

OnDownloadComplete() protected method

Raises the DownloadComplete event.
A completed download does not mean the entire file has been downloaded; the download may have been interrupted.
protected OnDownloadComplete ( bool p_booGotEntireFile, string p_strSavedFileName ) : void
p_booGotEntireFile bool Whether the entire file has been downloaded.
p_strSavedFileName string The path to the downloaded file.
return void

StartDownload() public method

Starts the file download.
public StartDownload ( ) : void
return void

Stop() public method

Stops the file download.
public Stop ( ) : void
return void