Search code examples
c#.netwpfapplication-name

How to get application name in WPF


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!


Solution

  • One approach would be:

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