Package Class
The Package class represents an installed application package on a Universal Windows Platform (UWP) device. It provides information about the application's identity, installation location, version, and related resources.
This class is part of the Windows.ApplicationModel namespace.
Usage
using Windows.ApplicationModel;
using System;
// Get the current package
Package currentPackage = Package.Current;
// Get package information
string packageName = currentPackage.Id.Name;
string packageVersion = currentPackage.Id.Version.ToString();
string installLocation = currentPackage.InstalledLocation.Path;
Console.WriteLine($"Package Name: {packageName}");
Console.WriteLine($"Package Version: {packageVersion}");
Console.WriteLine($"Install Location: {installLocation}");
Properties
| Name | Description |
|---|---|
| InstalledLocation | Gets the local folder where the package is installed. |
| IsDevelopmentMode | Gets a value indicating whether the package was installed in development mode. |
| LaunchActivatedBeta | Gets a value indicating whether the package is launched in beta mode. |
| PublisherDisplayName | Gets the display name of the package publisher. |
| InstalledDate | Gets the date and time when the package was installed. |
| Id | Gets the package identifier. |
Methods
| Name | Description |
|---|---|
| FindPackage(string packageName) | Finds a package by its name. |
| FindPackage(string packageName, string packageVersion) | Finds a package by its name and version. |
| LoadLifetimeManager() | Loads the package's lifetime manager. |
| GetAppListEntriesAsync() | Gets the list of app list entries for the package. |
Events
The Package class does not expose public events directly. Events related to package changes are typically handled through other system services.
Requirements
| API Supported in | Minimum supported client | Minimum supported server | Header files | Library files | DLL files |
|---|---|---|---|---|---|
| Windows 10 | Windows 10 | Windows Server 2016 | windows.applicationmodel.h |
WindowsApp.lib |
Windows.Foundation.Foundation.dll |
For more detailed information, refer to the official Microsoft documentation.