Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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)

public event DownloadFileGroupCompletedEventHandler DownloadFileGroupCompleted
/** @event */
public void add_DownloadFileGroupCompleted (DownloadFileGroupCompletedEventHandler value)

/** @event */
public void remove_DownloadFileGroupCompleted (DownloadFileGroupCompletedEventHandler value)

In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

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 a null reference (Nothing in Visual Basic), the download was successful; if it is not a null reference (Nothing in Visual Basic), 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..

private void DownloadFileGroupAsync(string fileGroup)
{
    if (ApplicationDeployment.IsNetworkDeployed)
    {
        ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

        try
        {
            if (deployment.IsFileGroupDownloaded(fileGroup))
            {
                deployment.DownloadFileGroupProgressChanged += new DeploymentProgressChangedEventHandler(deployment_DownloadFileGroupProgressChanged);
                deployment.DownloadFileGroupCompleted += new DownloadFileGroupCompletedEventHandler(deployment_DownloadFileGroupCompleted);

                deployment.DownloadFileGroupAsync(fileGroup);
            }
        }
        catch (InvalidOperationException ioe)
        {
            MessageBox.Show("This application is not a ClickOnce application. Error: " + ioe.Message);
            return;
        }
    }
}

void deployment_DownloadFileGroupProgressChanged(object sender, DeploymentProgressChangedEventArgs e)
{
    downloadStatus.Text = String.Format("Downloading file group {0}; {1:D}K of {2:D}K completed.", e.Group, e.BytesCompleted / 1024, e.BytesTotal / 1024);               
}

void deployment_DownloadFileGroupCompleted(object sender, DownloadFileGroupCompletedEventArgs e)
{
    if (e.Error != null)
    {
        downloadStatus.Text = "Could not download files. Will try again later.";
        return;
    }
    else if (e.Cancelled)
    {
        downloadStatus.Text = "The file download has been cancelled.";
        return;
    }

    downloadStatus.Text = String.Format("Download of file group {0} complete.", e.Group);
}

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.