WPF C# Unable to find subfolder image resource

2019-08-05 08:23发布

问题:

I have several images in an assembly that I have all marked as resource in their property setting.

For testing I put an image at the root of my project.

Img.Source = new BitmapImage(new Uri("pack://application:,,,/MyAssembly;component/image.png", UriKind.Absolute));            

and it finds and loads the image just fine.

If I place the image in a subfolder no matter what folder or what level, it returns back that it is unable to find the resource.

The folder structure is Resources/Base/Weather/image.png

Img.Source = new BitmapImage(new Uri("pack://application:,,,/MyAssembly;component/Resources/Base/Weather/image.png", UriKind.Absolute));            

When I run the application and try to load that image I get this error

Cannot locate resource 'resources/base/weather/image.png'.

Notice the lowercase on the folder names. I am at a loss as to what to try next. I have tried many variations including using the @ but that doesn't help. I really do not want to load up the root directory with images.

Thoughts Anyone???