How to get application name in WPF

2.6k Views Asked by At

Sometimes we need to get app name in WPF programmatically i.e.

icon.UriSource = new Uri("pack://application:,,,/AppName;component/Images/logo.ico");

How we can do it?

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

One approach would be:

icon.UriSource = new Uri(string.Format(
    "pack://application:,,,/{0};component/Images/logo.ico",
    Path.GetFileNameWithoutExtension(Application.ResourceAssembly.Location)));