Extracting data from a resx file using c#

.Net has a built-in reader (ResxResourceReader) and writer (ResxResourceWriter) which makes it really easy to read a resx file. The classes can be found in the System.Resources namespace under the System.Windows.Forms assembly (in System.Windows.Forms.dll)  

Basic Reader Example:

 
            var rsxr = new ResXResourceReader("demo.resx");

            foreach (DictionaryEntry d in rsxr)
            {
                Console.WriteLine(pathRelativeToStartingPath + ",\"" + d.Key + "\",\"" + d.Value + "\"");
            }

            rsxr.Close();           
         
            
Basic Writer Example:


            string txt = "One smart fellow, he felt smart";
            string txt_fr = "Un garçon intelligent, il se sentait à puce";


            ResXResourceWriter rsxw = new ResXResourceWriter("demo.resx");
            rsxw.AddResource("MyText", txt);
            rsxw.Close();

            ResXResourceWriter rsxw_fr = new ResXResourceWriter("demo.fr-FR.resx");
            rsxw_fr.AddResource("MyText", txt_fr);
            rsxw_fr.Close();    
  
            
Of course if you are putting images or media into your resx file you'll additional code to handle the different types that value can be.

A quick way to delete all the bin and obj folders in your solution

Something like this is a cinch with Powershell

1. open the powershell command prompt
2. enter the command get-childitem -path "C:\sourceCode\MySolution" -recurse -include obj,bin | remove-item -force -recurse

Handy for ensuring your solution will build from scratch with no unreferenced/circular referenced assemblies or for deleting dlls that have become locked which sometimes happens. Same principle could easily be applied to the asp.net cache.

How to obtain access to nested types through XAML

Answer: "+" indicates nested type in XAML

For example I want to access the View member on the Shipping type which is nested inside the Setup type e.g.

public struct Setup
{
  public struct Shipping
  {
    public const string View = "This is the value I want to access";
  }
}

The syntax would be CommandParameter="{x:Static demoAlias:Setup+Shipping.View}"