如何在UriKind.Relative Path中返回一个文件夹?

use*_*aro 1 wpf uri path relative-path

我有这个代码:

imgImage.Source = new BitmapImage(new Uri("Images/LivingRoom/chair.png", UriKind.Relative));
Run Code Online (Sandbox Code Playgroud)

这给了我:

{包://应用:,,,/ExpressFurnitureSystem;组件/ UI /图像/客厅/ chair.png}

在这里,我想删除(ui)或去一个文件夹.我的要求是:

{包://应用:,,,/ExpressFurnitureSystem;组件/图像/客厅/ chair.png}

因为我的图像文件夹下的所有图像文件都不在UI/Image下.

感谢您的帮助.

Dav*_*vid 5

你试过以下吗?(即在开头添加../)

imgImage.Source = new BitmapImage(new Uri("../Images/LivingRoom/chair.png", UriKind.Relative)); 
Run Code Online (Sandbox Code Playgroud)

我不确定是否会这样做,但通常两个时期允许你向上移动一个级别.