Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have written some piece of code in wpf c#, where i have given one simple image as a window background.
When I created exe file it works fine for me. But same exe same image same file path but doesn't work for others.

Turned out my image is of png format and other computer had jpg file.
So how do I create Exe file that can access any of the image format available in computer.


I am confused what to do. Can someone please share ideas?

What I have tried:

I just gave
<window.background>
......image is getting accessed here....



According to what I wrote there has to be clearly mentioned what type of image format i am accessing.

I want to create Exe which can access any type of image format as long as name is correct.
Posted
Comments
Dave Kreskowiak 1-Apr-22 14:47pm    
There's something wrong with your code. WPF apps can display PNG or JPG formats without doing anything special.

So what's the error message you're getting? Or are you making the mistake of swallowing the exception message in a try/catch block that does nothing?
Richard MacCutchan 2-Apr-22 4:43am    
You cannot use a fixed name in the XAML for the image if it is going to be different on different systems. You need to load it dynamically in your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900