This documentation is archived and is not being maintained.

ApplicationDeployment.DownloadFileGroupCompleted Event

Occurs on the main application thread when a file download is complete.

Namespace:  System.Deployment.Application
Assembly:  System.Deployment (in System.Deployment.dll)

'Declaration
Public Event DownloadFileGroupCompleted As DownloadFileGroupCompletedEventHandler
'Usage
Dim instance As ApplicationDeployment 
Dim handler As DownloadFileGroupCompletedEventHandler 

AddHandler instance.DownloadFileGroupCompleted, handler

The DownloadFileGroupCompleted event is called on the main application thread. It is thread safe to call your application's Windows Forms controls directly within this callback.

Check the Error property of the AsyncCompletedEventArgs supplied to this callback. If this property is Nothing, the download was successful; if it is not Nothing, the installation did not succeed, and you can find more information about the installation failure through the Error property.

The following code example downloads a group of Help files in the background. The example requires that you deploy a Windows Forms application that includes a StatusStrip control, and that this control contain a ToolStripStatusLabel control named downloadStatus..

Dim WithEvents ADDownloadHelpFiles As ApplicationDeployment

Private Sub DownloadHelpFiles(ByVal GroupName As String)
    If (ApplicationDeployment.IsNetworkDeployed) Then
        ADDownloadHelpFiles = ApplicationDeployment.CurrentDeployment

        If ADDownloadHelpFiles.IsFirstRun Then 
            Try 
                If Not ADDownloadHelpFiles.IsFileGroupDownloaded(GroupName) Then
                    ADDownloadHelpFiles.DownloadFileGroupAsync(GroupName)
                End If 
            Catch ioe As InvalidOperationException
                MessageBox.Show("This application is not a ClickOnce application.")
                Return 
            End Try 
        End If 
    End If 
End Sub 

Private Sub ADDownloadHelpFiles_DownloadFileGroupProgressChanged(ByVal sender As Object, ByVal e As DeploymentProgressChangedEventArgs) Handles ADDownloadHelpFiles.DownloadFileGroupProgressChanged
    DownloadStatus.Text = String.Format("Downloading file group {0}; {1:D}K of {2:D}K completed.", e.Group, e.BytesCompleted / 1024, e.BytesTotal / 1024)
End Sub 

Private Sub ADDownloadHelpFiles_DownloadFileGroupCompleted(ByVal sender As Object, ByVal e As DownloadFileGroupCompletedEventArgs) Handles ADDownloadHelpFiles.DownloadFileGroupCompleted
    DownloadStatus.Text = String.Format("Download of file group {0} complete.", e.Group)
End Sub

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: