PackageCatalog.AddResourcePackageAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将资源包添加到现有应用包。
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
包的资源 ID。
- 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; }));
}