IsFileGroupDownloaded Method

ApplicationDeployment.IsFileGroupDownloaded Method

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

Checks whether the named file group has already been downloaded to the client computer.

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

public bool IsFileGroupDownloaded (
	string groupName
)
public boolean IsFileGroupDownloaded (
	String groupName
)
public function IsFileGroupDownloaded (
	groupName : String
) : boolean

Parameters

groupName

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

Return Value

true if the file group has already been downloaded for the current version of this application; otherwise, false. If a new version of the application has been installed, and the new version has not added to, removed from, or altered files in the file group, IsFileGroupDownloaded will return true.

Exception typeCondition

InvalidDeploymentException

groupName is not a file group defined in the application manifest.

IsFileGroupDownloaded will work in a partially trusted application without any security demands.

When you update an application, ClickOnce will copy any on-demand data files from the previous version into the new version's data directory. If you download a new version of these files, you should remove any data you want to keep from the old version and move it into the new version.

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

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 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:
© 2016 Microsoft