2

I know you can get to Windows.ApplicationModel.Package.Current and use Id.Name to get the name, but this seems to be the Package Name in my manifest. A rather long string of numbers and letters.

How can I get to the Package Display Name, Publisher Display Name that are in the manifest from inside the code. I would rather make this dynamic.

Any suggestions?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
RallyRabbit
  • 433
  • 1
  • 8
  • 20

1 Answers1

2

The manifest is an xml file so you can query it with Linq to XML:

using System.Xml.Linq;
using Windows.ApplicationModel;
using Windows.Storage;

private async void GetInfo(object sender, RoutedEventArgs e)
{
    StorageFile file = await Package.Current.InstalledLocation.GetFileAsync("AppxManifest.xml");
    string manifestXml = await FileIO.ReadTextAsync(file);
    XDocument doc = XDocument.Parse(manifestXml);
    XNamespace packageNamespace = "http://schemas.microsoft.com/appx/2010/manifest";
    var displayName = (from name in doc.Descendants(packageNamespace + "DisplayName")
                       select name.Value).First();
    var publisherDsplName = (from publisher in doc.Descendants(packageNamespace + "PublisherDisplayName")
                             select publisher.Value).First();
    string output = "DisplayName: " + displayName + ", PublisherDisplayName: " + publisherDsplName;
    txtBlock.Text = output;
}
  • 1
    I don't particularly like that way. I'll just throw something in the resource files to cover these things and call it a day. – RallyRabbit Apr 29 '13 at 12:24