Search code examples
wpfpathurirelative-path

How to go back one folder in UriKind.Relative Path?


I have this code:

imgImage.Source = new BitmapImage(new Uri("Images/LivingRoom/chair.png", UriKind.Relative));

this gives me:

{pack://application:,,,/ExpressFurnitureSystem;component/ui/Images/LivingRoom/chair.png}

Here i want to delete (ui) or go one folder up. My requirement is:

{pack://application:,,,/ExpressFurnitureSystem;component/Images/LivingRoom/chair.png}

Because I have all my image files under Image folder not under UI/Image.

Thanks for your help in advance.


Solution

  • Have you tried the following? (i.e. Adding ../ at the beginning)

    imgImage.Source = new BitmapImage(new Uri("../Images/LivingRoom/chair.png", UriKind.Relative)); 
    

    I'm not sure if that will do it, but usually two periods allows you to move up one level.