November 20th, 2017

How can I find the installation directory for my UWP application?

After you’ve installed a UWP application, you may want to know where it got installed to. Maybe there’s a deployment bug that you’re trying to resolve. Maybe it’s just because you’re curious.

Programmatically, your application can ask for the Windows.Application­Model.Package.Current.Installed­Location.Path.

From PowerShell, you can say

Get-AppxPackage -Name YourPackageName

and it will print various tidbits about your package, including its Install­Location.

Bonus chatter: If you are retrieving the path programmatically because you want to reference content from it, you don’t need to get the path. You can use the ms-appx protocol to access your packaged content. For example

ms-appx:///Relative/Path/To/Content.jpg

references the specified a file relative to your install directory. Some components will accept a URI directly, such as Bitmap­Image.Uri­Source. If you need to convert it to a Storage­File, you can use Storage­File.Get­File­From­Application­Uri­Async.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.