0

I am trying to get an image from my projects resources and convert it to a Picture in a n WPF application, however when i get to the image I get a path that i cannot follow. ("P:\Projects\DocumentHandling\PictureHandler\bin\Debug\DocumentHandlingTouch.exe\..\..\Resources\pdf1.jpg") The picture does not show up. Othe images using the code below show up, just not the one from the resources portion.

        Picture p = new Picture();
        t.Content = filePath.Value;
        p.ToolTip = t;
        //External Program
        if (Path.GetExtension(filePath.Key.ToString()) == ".pdf")
        {
            var path = System.Reflection.Assembly.GetExecutingAssembly().Location + @"\..\..\Resources\pdf1.jpg";
            p.ImagePath = path;
        }

Is my path setup wrong in there? i need to display this image whenever a pdf file is needed. The program shows pictures from a database. but if its a pdf, obviously it wont show anything, so i'd like to show the image for it.

rigamonk
  • 1,179
  • 2
  • 17
  • 45

1 Answers1

0

If you want to load images from Resources follow instructions from here: Dynamically adding and loading image from Resources in C#

Community
  • 1
  • 1
Marcin Zablocki
  • 10,171
  • 1
  • 37
  • 47