Hey guys I'm making a program and in which the user can select a background image from their computer, but I have not found a way to save the picture to my.settings or my.resources
please help
Printable View
Hey guys I'm making a program and in which the user can select a background image from their computer, but I have not found a way to save the picture to my.settings or my.resources
please help
Well, My.Resources is ReadOnly, so it makes sense that you can't save the image to it.
I'm not sure you can use My.Settings for the BackgroundImage. I couldn't find a property for it in ApplicationSettings. Since My.Settings doesn't save files, that's probably why it can't do it.
Your only option would be to store the location of the background image somewhere.
My suggestion, would be to either use and external file, like an XML file, to store the location of the chosen background image. Alternatively, you can also use a registry key, which might be quicker and easier.
I came across a very good example of a background image changer on planet source code about a 5 months ago. I think this is the same one. example
Good Luck :wave:
If you did want to save an Image to My.Settings then you would do so as a base-64 encoded string. The Convert class has ToBase64String and FromBase64String methods to convert between String and Byte array. The String can be saved and loaded in My.Settings like any other String. To convert between an Image and a Byte array and vice versa, follow the CodeBank link in my signature and check out my thread on Saving Images In Databases.
Note that the Framework already uses basically this same mechanism to store images in RESX files.