0

I'm having a heck of a time loading an image from the path where the program is being run.

    Dim image As New BitmapImage
    Dim imagePath As String = "keepass.png"
    image.BeginInit()
    image.UriSource = New Uri(imagePath, UriKind.Relative)
    image.EndInit()

    ProductImage.Source = image

I can't seem to use a relative path to my image. If I put an absolute value in there, it shows. I'm in debug mode and have the image in the debug folder. This should work, shouldn't it? I've had this problem in other projects too!

1
Contributor
1
Reply
19
Views
3 Years
Discussion Span
Last Post by ZeroZen
0

I found a solution, but it doesn't use the relative path.

    Dim image As New BitmapImage
    image.BeginInit()
    image.UriSource = New Uri(Environment.CurrentDirectory & "\" & ProductImageLocation, UriKind.Absolute)
    image.EndInit()
    ProductImage.Source = image

I'm left wondering why the relative path doesn't work as I expect it to?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.