Click here to Skip to main content
13,201,451 members (73,612 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 29 Dec 2004

Fireball Resourcer

, 29 Dec 2004
Rate this:
Please Sign up or sign in to vote.
Embeding resources on application with base64 alghoritm.

Sample Image - FireballResourcer.png


Fireball Resourcer is a Windows Forms application written for simple generation of resources to embed it on your application without using .resx or .resources. Fireball Resourcer uses a simple method. It converts all resource images, icons and text files to an encoded string with base64 algorithm for putting it on a static class. This class contains some methods to decode the resources to an Image object, Icon object or a String object. I have developed this system because it is very practical to use. With this, you will not have the risk of losing data and this is common with ImageList and other resource systems on .NET.

Fireball Resourcer is provided with a nice interface for inserting resources as images, sounds and icons, on menu File -> Export. You are free to choose to export all as a C# class or VB.NET or export as a compiled assembly. The compatibility for the moment is for C# 2.0, but if you are using .NET 1.1 as your development platform, you need to remove a little set of instructions that are not supported on the old framework.

The encryption and decryption classes are composed by some methods, but the most important are these:

private char[] EncodeResourceToBase64(string resource,string restype)  {
     byte[] binData;
          // If a resource is a string
          // trasform it as a array of bytes
          binData= StringToByteArray(resource);
          // Load the file as a stream
          // and load bytes on the array
          FileStream sfile;
               sfile=new FileStream(resource,FileMode.Open,FileAccess.Read);
               binData=new byte[sfile.Length];
               long bytesRead=sfile.Read(binData,0,(int)sfile.Length);
          catch(Exception ex)
               throw ex;

     // Convert the binary input on output as a base64 UUEncoded
     // 3 byte of the sequenze they become 4 char of the array
     long arrayLen=(long)((4.0d/3.0d)*binData.Length);
     //if the array is not divisibile for 4 pass ti the next multiple of 4
     if((arrayLen % 4)!=0)

     char[] base64CharArray=new char[arrayLen];
          return base64CharArray;
     catch(ArgumentNullException ex)
         throw new ArgumentNullException(ex.ParamName,ex.Message);
     catch(ArgumentOutOfRangeException ex)
          throw new ArgumentOutOfRangeException(ex.ParamName,ex.Message);

Another important function is decode. See this code:

private object DecodeResourceFromBase64(string resource,string restype)
     object retobj = null;
     byte[] memBytes = Convert.FromBase64String(resource);
     IFormatter formatter =
       new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
     MemoryStream stream = new MemoryStream(memBytes);

         retobj = System.Text.Encoding.UTF8.GetString(memBytes);
               retobj =Image.FromStream(stream);
               retobj =new Icon(stream);
                retobj =new System.Windows.Forms.Cursor(stream);
               //TODO: other type
               //retobj =formatter.Deserialize(stream);
       return retobj;

I successfully use this system on my applications for embedding icons and images on my assembly. This software is in beta, but is functioning. If you find bugs or new ideas to implement, please contact me.

It is all. If you have any question about the code, please contact me with a comment on this article or by my forum.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Italy Italy
No Biography provided

You may also be interested in...


Comments and Discussions

Generalerror Pin
guns_zdz@163.com19-Jun-06 19:13
memberguns_zdz@163.com19-Jun-06 19:13 
GeneralThis is Beta 2 code and should be updated to RTM Pin
Keia13-Feb-06 22:13
memberKeia13-Feb-06 22:13 
Generalquestion Pin
tang198331-Oct-05 15:15
membertang198331-Oct-05 15:15 
Generaldon't Open Pin
whiteisgem11-Sep-05 14:08
memberwhiteisgem11-Sep-05 14:08 
GeneralRe: don't Open Pin
Anonymous11-Sep-05 23:37
sussAnonymous11-Sep-05 23:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171020.1 | Last Updated 29 Dec 2004
Article Copyright 2004 by dotnetfireball
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid