Results 1 to 4 of 4
  1. #1
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead

    [Tutorial] Programmatically Creating / Updating a *.Resx File

    Hi, I was working on a project and needed to add resources to the project in real time. This is done by updating the *.Resx file located in the project directory. Luckily browsing through the Resources namespace I found the ResXResourceWriter class. Before I demonstrate on how to use the class, take a look at what the .Resx file is:

    A *.Resx file is a block of XML data that assigns name/value pairs for each resource in your application.

    The ResXResourceWriter class provides a set of members that allow you to create the *.Resx files.

    Let's create an independent *.Resx file.

    ■ First create a new project in vb.
    ■ On the main form, drag a button from the toolbox. Set its text to "Generate *.Resx File".
    ■ Now double click the button to go to its "Click" event. When the click event shows up, add the following code to it:

    'Change to a valid picture location...
    Dim PictureToAdd As String = "C:\Users\AUser\Pictures\30651_124206260947142_100 000733059464_175037_5040347_n.jpg"
    'Change it to where you want to store your new *.Resx file...
    Dim ResxFilename As String = "F:\ResXForm.resx"
    'Create a new instance of the Writer...
    Dim ResWriter As New ResXResourceWriter(ResxFilename)
    'Create the bitmap...
    Dim Pic As New Bitmap(PictureToAdd)
    'Finally add the picture to your resources, here Kai Hiwatari is the name of the resource and Pic is the value of it. This means that the a new resource will be added with Kai Hiwatari as its name and the picture we defined above as its value...
    ResWriter.AddResource( "Kai Hiwatari",Pic)
    'Similarly create custom strings...
    ResWriter.AddResource( "FlameSaber", "VB.NET Coder")
    'Finally create the *.Resx file...
    ResWriter.Generate()
    'Close the writer so it can free the occupied resources...
    ResWriter.Close()

    ■ Also, add this namespace to the form to refer the ResxResourceWriter class:

    Imports System.Resources

    Using the similarly technique, you can update the resources of your project in real time. All you need to do is change the variable "ResxFileName" to your project's *.Resx filename.

    Here's where your values are added:


    This becomes really helpful when you need to give some control to the end user.

    Hope this helps !!
    Enjoy !!

  2. The Following 3 Users Say Thank You to Hassan For This Useful Post:

    Invidus (06-04-2010),Lolland (06-04-2010),ppl2pass (06-04-2010)

  3. #2
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy
    Awesome flame!
    Thanks for sharing!
    -Rest in peace leechers-

    Your PM box is 100% full.

  4. The Following User Says Thank You to Zoom For This Useful Post:

    Hassan (06-04-2010)

  5. #3
    Invidus's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    2,167
    Reputation
    23
    Thanks
    650
    My Mood
    Bored
    Wow good job flame!
    AND GET THAT MINION

  6. The Following User Says Thank You to Invidus For This Useful Post:

    Hassan (06-04-2010)

  7. #4
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Good article

  8. The Following User Says Thank You to Lolland For This Useful Post:

    Hassan (06-04-2010)

Similar Threads

  1. [Tutorial] How to post a Hack/File on MPGH + Hosting Sites
    By Zoom in forum Combat Arms Hacks & Cheats
    Replies: 3
    Last Post: 04-08-2011, 02:27 AM
  2. [Tutorial] How to post a Hack/File on MPGH.NET[Step by Step]
    By Zoom in forum Combat Arms Europe Hacks
    Replies: 0
    Last Post: 05-28-2010, 03:39 PM
  3. Update on LTB files
    By treeham in forum Combat Arms Mod Discussion
    Replies: 3
    Last Post: 01-17-2010, 02:38 PM
  4. [RELEASE] Update on ltb files
    By treeham in forum Combat Arms Mods & Rez Modding
    Replies: 3
    Last Post: 01-14-2010, 12:03 AM
  5. Using only the Ipod touch to create and compile source files
    By radnomguywfq3 in forum C++/C Programming
    Replies: 3
    Last Post: 03-22-2009, 11:26 AM

Tags for this Thread