PackageCatalog.AddResourcePackageAsync 方法

定義

將資源套件新增至現有的應用程式套件。

public:
 virtual IAsyncOperationWithProgress<PackageCatalogAddResourcePackageResult ^, PackageInstallProgress> ^ AddResourcePackageAsync(Platform::String ^ resourcePackageFamilyName, Platform::String ^ resourceID, AddResourcePackageOptions options) = AddResourcePackageAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<PackageCatalogAddResourcePackageResult, PackageInstallProgress> AddResourcePackageAsync(winrt::hstring const& resourcePackageFamilyName, winrt::hstring const& resourceID, AddResourcePackageOptions const& options);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<PackageCatalogAddResourcePackageResult,PackageInstallProgress> AddResourcePackageAsync(string resourcePackageFamilyName, string resourceID, AddResourcePackageOptions options);
function addResourcePackageAsync(resourcePackageFamilyName, resourceID, options)
Public Function AddResourcePackageAsync (resourcePackageFamilyName As String, resourceID As String, options As AddResourcePackageOptions) As IAsyncOperationWithProgress(Of PackageCatalogAddResourcePackageResult, PackageInstallProgress)

參數

resourcePackageFamilyName
String

Platform::String

winrt::hstring

可唯一識別應用程式套件的套件系列名稱。

resourceID
String

Platform::String

winrt::hstring

封裝的資源識別碼。

options
AddResourcePackageOptions

將資源套件新增至應用程式時,指定行為的選項。

傳回

新增資源套件的進度報告。

屬性

Windows 需求

裝置系列
Windows 10, version 1803 (已於 10.0.17134.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v6.0 引進)

範例

async void btnInstallFrenchProofingTools_Click(object sender, EventArgs e) 
{ 
    var packageCatalog = PackageCatalog.OpenForCurrentPackage(); 
    string familyName = "Microsoft.Word_8wekyb3d8bbwe"; 
    // The resourceId specified in the AppxManifest.xml should be unique within a PackageFamily
    string resourceId = "FR_ProofingTools"; 

    // Install the resource package and start reporting progress on the current 
    // progressBar in the UI
    var installedPackage = await packageCatalog.AddResourcePackageAsync(familyName, resourceId, AddResourcePackageOptions.RestartApplication) 
    .AsTask<PackageCatalogAddResourcePackageResult, PackageInstallProgress>(new Progress<PackageInstallProgress> 
    (progress => { progressBar.CurrentValue = progress.PercentComplete; })); 
} 

適用於