C# Class FileDownloaderApp.FileDownloader

Class for downloading files in the background that supports info about their progress, the total progress, cancellation, pausing, and resuming. The downloads will run on a separate thread so you don't have to worry about multihreading yourself.
Class FileDownloader v1.0.2, by De Dauw Jeroen - April 2009
Inheritance: System.Object, IDisposable
Exibir arquivo Open project: polserver/poltools Class Usage Examples

Public Methods

Method Description
CurrentFilePercentage ( ) : Double

Gets the percentage of the current file progress

CurrentFilePercentage ( Int32 decimals ) : Double

Gets the percentage of the current file progress

Dispose ( ) : void
FileDownloader ( ) : System

Create a new instance of a FileDownloader

FileDownloader ( System.Boolean supportsProgress ) : System

Create a new instance of a FileDownloader

FormatSizeBinary ( System.Int64 size ) : string

Format an amount of bytes to a more readible notation with binary notation symbols

FormatSizeBinary ( System.Int64 size, Int32 decimals ) : string

Format an amount of bytes to a more readible notation with binary notation symbols

FormatSizeDecimal ( System.Int64 size ) : string

Format an amount of bytes to a more readible notation with decimal notation symbols

FormatSizeDecimal ( System.Int64 size, Int32 decimals ) : string

Format an amount of bytes to a more readible notation with decimal notation symbols

Pause ( ) : void
Resume ( ) : void
Start ( ) : void
Stop ( ) : void
Stop ( System.Boolean deleteCompletedFiles ) : void
TotalPercentage ( ) : Double

Gets the total download percentage. Only avaible when the FileDownloader suports progress

TotalPercentage ( Int32 decimals ) : Double

Gets the total download percentage. Only avaible when the FileDownloader suports progress

Protected Methods

Method Description
Dispose ( System.Boolean disposing ) : void

Private Methods

Method Description
bgwDownloader_DoWork ( object sender, DoWorkEventArgs e ) : void
bgwDownloader_ProgressChanged ( object sender, ProgressChangedEventArgs e ) : void
bgwDownloader_RunWorkerCompleted ( object sender, RunWorkerCompletedEventArgs e ) : void
calculateFilesSize ( ) : void
cleanUpFiles ( Int32 start, Int32 length ) : void
downloadFile ( Int32 fileNr ) : void
fireEventFromBgw ( Event eventName ) : void
initizalize ( System.Boolean supportsProgress ) : void

Method Details

CurrentFilePercentage() public method

Gets the percentage of the current file progress
public CurrentFilePercentage ( ) : Double
return Double

CurrentFilePercentage() public method

Gets the percentage of the current file progress
public CurrentFilePercentage ( Int32 decimals ) : Double
decimals System.Int32
return Double

Dispose() public method

public Dispose ( ) : void
return void

Dispose() protected method

protected Dispose ( System.Boolean disposing ) : void
disposing System.Boolean
return void

FileDownloader() public method

Create a new instance of a FileDownloader
public FileDownloader ( ) : System
return System

FileDownloader() public method

Create a new instance of a FileDownloader
public FileDownloader ( System.Boolean supportsProgress ) : System
supportsProgress System.Boolean Optional. Boolean. Should the FileDownloader support total progress statistics?
return System

FormatSizeBinary() public static method

Format an amount of bytes to a more readible notation with binary notation symbols
public static FormatSizeBinary ( System.Int64 size ) : string
size System.Int64 Required. Int64. The raw amount of bytes
return string

FormatSizeBinary() public static method

Format an amount of bytes to a more readible notation with binary notation symbols
public static FormatSizeBinary ( System.Int64 size, Int32 decimals ) : string
size System.Int64 Required. Int64. The raw amount of bytes
decimals System.Int32 Optional. Int32. The amount of decimals you want to have displayed in the notation
return string

FormatSizeDecimal() public static method

Format an amount of bytes to a more readible notation with decimal notation symbols
public static FormatSizeDecimal ( System.Int64 size ) : string
size System.Int64 Required. Int64. The raw amount of bytes
return string

FormatSizeDecimal() public static method

Format an amount of bytes to a more readible notation with decimal notation symbols
public static FormatSizeDecimal ( System.Int64 size, Int32 decimals ) : string
size System.Int64 Required. Int64. The raw amount of bytes
decimals System.Int32 Optional. Int32. The amount of decimals you want to have displayed in the notation
return string

Pause() public method

public Pause ( ) : void
return void

Resume() public method

public Resume ( ) : void
return void

Start() public method

public Start ( ) : void
return void

Stop() public method

public Stop ( ) : void
return void

Stop() public method

public Stop ( System.Boolean deleteCompletedFiles ) : void
deleteCompletedFiles System.Boolean
return void

TotalPercentage() public method

Gets the total download percentage. Only avaible when the FileDownloader suports progress
public TotalPercentage ( ) : Double
return Double

TotalPercentage() public method

Gets the total download percentage. Only avaible when the FileDownloader suports progress
public TotalPercentage ( Int32 decimals ) : Double
decimals System.Int32
return Double