Windows通用URI格式异常

Wer*_*Boy 1 uri exception windows-8.1 windows-phone-8.1 win-universal-app

我正在开发一个Windows通用应用程序.我想向用户显示图像.该图像位于我的资源文件夹中的子文件夹中,位于手机和Windows文件夹中.

我正在尝试将图像放在共享文件夹中的类中的变量中.我不断得到uri例外.

我的代码看起来像这样:

Uri uri = new Uri("/Assets/Image/avatar_anonymous.png");
chat_profilepicture_Bitmap = new BitmapImage(uri);
Run Code Online (Sandbox Code Playgroud)

我尝试了不同的网址,无论是否有大写字母,整个路径都是"C:// blablabla"等等.似乎没有什么工作.我也尝试过:pack:// application:,,, /这是多个stackoverflow线程建议的.但那里没有运气.

我认为问题在于图像在另一个项目中,有没有办法解决这个问题?或者,如果这不是问题,我做错了什么?

Muh*_*lah 5

试试这个

Uri uri = new Uri("ms-appx:///Assets/Image/avatar_anonymous.png");
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助