Share via


ApplicationDeployment.DownloadFileGroupAsync Method

Definition

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

Overloads

DownloadFileGroupAsync(String, Object)

Downloads, on demand, a set of optional files in the background, and passes a piece of application state to the event callbacks.

DownloadFileGroupAsync(String)

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

DownloadFileGroupAsync(String, Object)

Downloads, on demand, a set of optional files in the background, and passes a piece of application state to the event callbacks.

public:
 void DownloadFileGroupAsync(System::String ^ groupName, System::Object ^ userState);
public void DownloadFileGroupAsync (string groupName, object userState);
member this.DownloadFileGroupAsync : string * obj -> unit
Public Sub DownloadFileGroupAsync (groupName As String, userState As Object)

Parameters

groupName
String

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

userState
Object

An arbitrary object containing state information for the asynchronous operation.

Exceptions

The groupName parameter is null or zero-length.

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

Remarks

In a ClickOnce application, the 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 approach 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.

You can download multiple file groups simultaneously by using the DownloadFileGroupAsync method. 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 a more complex state, you can use

DownloadFileGroupAsync to pass in a state object.

All static files are downloaded to the ClickOnce application's data directory and are therefore isolated to the current version of the application. For more information about accessing static files, see Accessing Local and Remote Data in ClickOnce Applications. . Let's say that after an application downloads a file group, the user installs a new version of the application, but later 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.

DownloadFileGroup works in partially trusted applications, that is, in any ClickOnce application running with restricted permission. However, if you are attempting to load assemblies dynamically, your application will require full trust.

On-demand downloading of data files is currently not supported.

To cancel an asynchronous download, call the DownloadFileGroupAsyncCancel method.

See also

Applies to

DownloadFileGroupAsync(String)

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

public:
 void DownloadFileGroupAsync(System::String ^ groupName);
public void DownloadFileGroupAsync (string groupName);
member this.DownloadFileGroupAsync : string -> unit
Public Sub DownloadFileGroupAsync (groupName As String)

Parameters

groupName
String

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

Exceptions

The groupName parameter is null or zero-length.

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

Remarks

In a ClickOnce application, the 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 approach 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.

All assemblies are downloaded to the ClickOnce application cache.

All static files are downloaded to the ClickOnce application's data directory and are therefore isolated to the current version of the application. Let's say that after an application downloads a file group, the user installs a new version of the application, but later 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.

DownloadFileGroup works in partially trusted applications, that is, in any ClickOnce application running with restricted permission. However, if you are attempting to load assemblies dynamically, your application will require full trust.

On-demand downloading of data files is currently not supported.

You cannot download a single file by its file name 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.

See also

Applies to