图像路径[C#,WPF]有问题

图像路径[C#,WPF]有问题,c#,wpf,uri,relative-path,wpf-4.0,C#,Wpf,Uri,Relative Path,Wpf 4.0,我需要在2.NET程序集中使用图像。一个是wpfapp{myApp.exe},第二个是*.dll{myDll.dll}。文件位于此文件结构中: **AppFolder** consist these files and one subfolder(avatars): -myApp.exe -myDll.dll -avatars {folder} consist: -manImages.jpg -womanImages.jpg 但是

我需要在2.NET程序集中使用图像。一个是wpfapp{myApp.exe},第二个是*.dll{myDll.dll}。文件位于此文件结构中:

**AppFolder** consist these files and one subfolder(avatars): -myApp.exe -myDll.dll -avatars {folder} consist: -manImages.jpg -womanImages.jpg 但是这种格式不起作用,图像是空的

我希望

new Uri(@"avatars\manImages.jpg", UriKind.RelativeOrAbsolute);
工作

您也可以尝试:

new Uri(Environment.CurrentDirectory + @"\avatars\manImages.jpg", UriKind.RelativeOrAbsolute);

在dll端,您可以编写以下内容:

string imgPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "avatars\\manImages.jpg");

我的印象是,他希望新的URL语句能够工作。这是对那个问题的回答。我遗漏了什么吗?霍根,在我的问题中,C:\Users\avatars\manImages.jpg中有一个错误,应该是avatars\manImages。但它不起作用。此选项四:返回新Uri(Environment.CurrentDirectory+@“\avatars\man.jpg”,UriKind.RelativeOrAbsolute);工作用品。非常感谢。
string imgPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "avatars\\manImages.jpg");