Xaml - Bitmap UriSource - absolute path works, relative path does not, why?

前端 未结 2 556
感情败类
感情败类 2020-12-19 06:55

I\'m, a WPF & Xaml-noob, for console applications it has worked for me to simply give the relative path to the executable to access a file. It doesn\'t seem to work in x

2条回答
  •  温柔的废话
    2020-12-19 07:27

    URIs can be confusing, as they can refer to both files on disk and resources in the application. So a relative path could be to a resource in the app, when you intend it to be on disk.

    You can use the siteoforigin authority to force relative file URIs. This blog explains this more, but here an example:

    pack://siteoforigin:,,,/path4.ico
    

提交回复
热议问题