Bagikan melalui


PackageCatalog.RemoveOptionalPackagesAsync(IIterable<String>) Metode

Definisi

Menghapus paket aplikasi opsional yang diinstal dari akun pengguna.

public:
 virtual IAsyncOperation<PackageCatalogRemoveOptionalPackagesResult ^> ^ RemoveOptionalPackagesAsync(IIterable<Platform::String ^> ^ optionalPackageFamilyNames) = RemoveOptionalPackagesAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<PackageCatalogRemoveOptionalPackagesResult> RemoveOptionalPackagesAsync(IIterable<winrt::hstring> const& optionalPackageFamilyNames);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<PackageCatalogRemoveOptionalPackagesResult> RemoveOptionalPackagesAsync(IEnumerable<string> optionalPackageFamilyNames);
function removeOptionalPackagesAsync(optionalPackageFamilyNames)
Public Function RemoveOptionalPackagesAsync (optionalPackageFamilyNames As IEnumerable(Of String)) As IAsyncOperation(Of PackageCatalogRemoveOptionalPackagesResult)

Parameter

optionalPackageFamilyNames

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

Daftar string nama keluarga paket opsional.

Mengembalikan

Hasil dari menghapus paket opsional dalam bentuk: PackageCatalogRemoveOptionalPackagesResult.

Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 Fall Creators Update (diperkenalkan dalam 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v5.0)

Contoh

Sampel ini menunjukkan penghapusan semua paket opsional dari paket aplikasi utama.

public async void RemoveOptionalPackages() 
{ 
    // Create a list of the optional package family names
    List<string> optionalPackageList = new List<string>(); 
    foreach (var package in Windows.ApplicationModel.Package.Current.Dependencies) 
    { 
        if (package.IsOptional) 
        { 
            optionalPackageList.Add(package.Id.FamilyName); 
        } 
    } 

    // Remove the optional packages from the list    
    PackageCatalog catalog = Windows.ApplicationModel.PackageCatalog.OpenForCurrentPackage(); 
    var removalResult = await catalog.RemoveOptionalPackagesAsync(optionalPackageList); 
    if (removalResult.ExtendedError != null) 
    { 
        throw removalResult.ExtendedError; 
    } 
}

Keterangan

Nama keluarga paket dapat ditemukan di properti FamilyName dari PackageId.

Berlaku untuk