سؤال

I need use images in 2 .NET assemblies. One is WPF app {myApp.exe} and second is *.dll {myDll.dll}. File are 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");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top