DownloadFileGroupAsync Method (String)
Collapse the table of content
Expand the table of content

ApplicationDeployment.DownloadFileGroupAsync Method (String)

Note: This method is new in the .NET Framework version 2.0.

Downloads, on-demand, a set of optional files in the background.

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

void DownloadFileGroupAsync (
	String^ groupName
public void DownloadFileGroupAsync (
	String groupName
public function DownloadFileGroupAsync (
	groupName : String



The named group of files to download. All files marked "optional" in a ClickOnce application require a group name.

Exception typeCondition


groupName parameter is null or zero-length.


You cannot initiate more than one download of groupName at a time.

In a ClickOnce application, all files marked "optional" in the application manifest are not downloaded during initialization or update. You can use the DownloadFileGroupAsync method to download all of the files belonging to a named group on demand, so that they do not consume network resources and disk space until you are sure the user requires them. This works not only for static files, but also for assemblies that an application may or may not require. For example, certain users may need to use a data analysis package included in your application on a daily basis, while other users may never invoke it. To download assemblies on demand, attach an event listener to the AssemblyResolve event on the CurrentDomain. For an example, see Walkthrough: Downloading Assemblies On Demand with the ClickOnce Deployment API Using the Designer.

All assemblies are downloaded to the ClickOnce application cache.

All static files are downloaded to the ClickOnce application's data directory. Because of this, the files are isolated to the current version of the application. Say that an application downloads a file group, and then the user installs a new version. Later, the user reverts to the previous version of the application. In this case, the previous version will still have the copies of the files it originally downloaded. For more information about accessing static files, see Accessing Local and Remote Data in ClickOnce Applications.

You can download multiple file groups simultaneously using DownloadFileGroupAsync. You can distinguish among them by using the Group property of the DeploymentProgressChangedEventArgs class, which is passed to the DownloadFileGroupProgressChanged event. If you need to pass more complex state, you can use

DownloadFileGroupAsync to pass in a state object that is passed to the DownloadFileGroupCompleted event through the UserState property.

DownloadFileGroup works in partially trusted applications, that is, any ClickOnce application running with restricted permission.

Data files downloaded as part of a ClickOnce application are migrated from one version to the next version according to a specific set of rules. For more information, see Accessing Local and Remote Data in ClickOnce Applications.

There is no way to download a single file by the name of the file alone. To download a single file, assign it a group name in your ClickOnce deployment and download the group using this method.

To cancel an asynchronous download, call the DownloadFileGroupAsyncCancel method.

The following code example downloads a group of help files in the background.

void LaunchAppUpdate()
    if (ApplicationDeployment::IsNetworkDeployed)
        ApplicationDeployment^ ad =
        ad->UpdateCompleted +=
            gcnew AsyncCompletedEventHandler(this,


void LaunchAppUpdate_UpdateCompleted(Object^ sender,
    AsyncCompletedEventArgs^ e)
    if (!e->Cancelled)
        if (nullptr != e->Error)
            System::Windows::Forms::DialogResult dr =
                "The application has been updated. Restart?",
                "Restart Application",
            if (System::Windows::Forms::DialogResult::OK == dr)
            // Replace with your own error reporting or logging.
                "The application encountered an error in " +
                "downloading the latest update. Error: {0}",
        // Replace with your own error reporting or logging.
            "The update of the application's latest version was " +

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

© 2016 Microsoft