Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to change the image file on a runtime without effecting my exe.

What I have tried:

i put two images in my project and change the build action of one image from none to resource and the other from none to content and set copy to directory as "Copy Always".when i am deleting my image from my debug folder whose build action is content and running my exe both images appeared no effect on exe if i delete that one image.
Posted
Updated 17-Jan-18 1:24am
Comments
PureNsanity 17-Jan-18 19:20pm    
When changing just the build properties, you may need to rebuild the project. Not going to put this as a solution because I have never actually bothered to take the time to research the validity, but for my projects it's what I recall needing to do (and am doing now).

1 solution

If your image is embedded, you can't change it at run time without rebuilding the EXE file. If it isn't embedded, then it is external to your EXE when it's built and will need to be copied to the production folder along with the EXE file by your installer.

Under those circumstances, I wouldn't recommend changing the file - it'll work in development, but will likely fail in production because the installation directory will be under "Program files" and security measures do not allow modifications there without Admin access.

What I would do is store the image(s) in the user data area - and copy them there from your installer - where they can be changed without problems. See here: Where should I store my data?[^] - it shows where to store data and how to access it.
 
Share this answer
 
Comments
Robin Purbia 17-Jan-18 7:54am    
If your image is embedded, you can't change it at run time without rebuilding the EXE file.my image is not embedded it is content and then i am changing my image still nothing effect on my exe.when i change the exe should reflect the new image but it didn't...

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