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

前端 未结 2 544
感情败类
感情败类 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
    
    0 讨论(0)
  • 2020-12-19 07:28

    Relative paths without qualifications look up the referenced file in the application resources, if a path should be relative to the executable you can use pack://siteoforigin:,,,/path4.ico, see Pack URIs on MSDN.

    0 讨论(0)
提交回复
热议问题