Decoding Base64 & Saving Result To Temp Directory

I’d like to “bundle” a couple of small-ish binary data files in with one of my projects and then have the data files temporarily available for use when running the application…

From reading several posts here, it seems that a few others have wanted to do something similar (usually involving pictures rather than data though). Anyway, converting the data files to Base64, storing the resulting text in a constant and then decoding & saving when needed would be a way of doing what I think I want…

Unfortunately my lack of experience (or lack of ability) with XOJO is letting me down now though. I can use something like https://www.base64encode.org/ to encode my data to the base64 format and I’ve figured out how to create constants. But I don’t know how to proceed any further.

If someone has a spare 5/10 mins, could you give me an example of how to decode a base64 string stored in a constant and save the resulting file to a directory on a hard disk (say in C:\Temp\).

Thank you

You know, there’s a number of great resources for beginners.

First, if you’re an absolute beginner to programming, there’s the textbook. It teaches you to program as well as use Xojo at the same time. Great two-in-one system.

There’s also a manual that comes with Xojo that teaches you the ins and outs of using the IDE, the language, and the features within. You can find that in the Documentation folder next to your installation of Xojo. There’s also an online reference http://documentation.xojo.com

Lastly, when you’re ready to learn from examples, there’s a folder full of example projects next to your Xojo install called “Example Projects” It helps when you don’t intend to reinvent the wheel. Do not copy and paste code from example projects, that won’t help you at all.

Best of luck to you :slight_smile:

Xojo has a DecodeBase64 method that makes this really easy:

Dim data As String = DecodeBase64(MYCONSTANT) Dim p As Picture = Picture.FromData(data)

Sorted how to do it now…

Cheers =)

Dim f As FolderItem = SpecialFolder.Desktop.Child("config.win") Dim bs As BinaryStream = BinaryStream.Create(f, true) bs.Write(DecodeBase64(constant_name)) bs.Close