Export (0) Print
Expand All

ApplicationDeployment.DownloadFileGroup Method

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

Downloads, on-demand, a set of optional files.

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

public void DownloadFileGroup (
	string groupName
)
public void DownloadFileGroup (
	String groupName
)
public function DownloadFileGroup (
	groupName : String
)

Parameters

groupName

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

Exception typeCondition

ArgumentNullException

groupName parameter is null or zero-length.

In a ClickOnce application, all files marked "optional" in the application manifest are not downloaded during initialization or update. You can use the DownloadFileGroup 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 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.

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.

Your application will not be responsive to user input until this method returns. If you need to download files without interrupting the user's workflow, use the DownloadFileGroupAsync method instead.

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.

The following code example synchronously downloads all of the files in the HelpFiles group to disk.

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

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

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


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

ADD
Show:
© 2014 Microsoft