Search code examples
wpfimagefilepathrelative-path

WPF Dispay image from relative location


I would like to display an image on my dialog which could be located in a directory relative to the one the .exe is located in, e.g.

project
- data
 -- logo  //<-- that's where the image is located
-bin      //<-- that's where the .exe is in

A default image should be included in the .exe but on displaying the dialog, the \data\logo directory should be checked first and if an image with the given filename could be found there that one should be used for display instead of the one that is inside the .exe.

Any ideas on how to do this?

Thanks,

tabina


Solution

  • Use the pack URI

    pack://application:,,,/ReferencedAssembly;component/data/logo/image.png