开发者

Problem with image path [C#, WPF]

I need use images in 2 .NET assemblies. One is WPF app {myApp.exe} and second is *.dll {myDll.dll}. File are 开发者_C百科located in this file structure:

 **AppFolder** consist these files and one subfolder(avatars):

    -myApp.exe
    -myDll.dll
    -avatars {folder} consist:
          -manImages.jpg
          -womanImages.jpg

I try user uri in this format

new Uri(@"C:\Users\avatars\manImages.jpg", UriKind.RelativeOrAbsolute);

but this format does not work, images are empty.


I would expect

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

to work?

You could also try:

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


On the dll side you can write this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜