locked
Convert .resx file to .resources programmatically RRS feed

  • Question

  • Hello All
    Is there any other way apart from using the resgen  tool to generate .resource file from a .resx file
    Are there any readymade classes (may be ResourceWriter, ResXResourceReader) available in .NET just for this purpose ??


    Regards
    Srivatsa
    Tuesday, March 11, 2008 4:08 AM

Answers

  • I don't know how to do it from a resx file, but from an assembly it is using reflection like this :

     

    Assembly assembly = Assembly.ReflectionOnlyLoadFrom(@"c:\windows\microsoft.NET\Framework\V2.0.50727\System.design.dll");

     

    string[] names = assembly.GetManifestResourceNames();

    foreach (string name in names)

    {

    Stream s = assembly.GetManifestResourceStream(name);

    FileStream fs = new FileStream(name, FileMode.Create);

    BinaryWriter writer = new BinaryWriter(fs);

    byte[] buffer = new byte[s.Length];

    s.Read(buffer, 0, (int)s.Length);

    fs.Write(buffer, 0, (int)s.Length);

    fs.Close();

    s.Close();

    }

     

     

    Wednesday, March 12, 2008 11:24 AM

All replies

  • Hi,

    look at this:

    http://edndoc.esri.com/arcobjects/9.0/ArcGISDevHelp/DevelopmentEnvs/DotNet/WorkingWithResources.htm#Compiling_resx_file
    Tuesday, March 11, 2008 8:21 AM

  • Hello Mykhaylo ...
    Thanks for ur reply and your time ... i know all these methods but i already have some .resx files with me ...
    But I want to write a tool for myself wherein it picks up each .resx file and writes it into a .resource file.

    Regards
    Srivatsa


    Wednesday, March 12, 2008 5:18 AM
  • I don't know how to do it from a resx file, but from an assembly it is using reflection like this :

     

    Assembly assembly = Assembly.ReflectionOnlyLoadFrom(@"c:\windows\microsoft.NET\Framework\V2.0.50727\System.design.dll");

     

    string[] names = assembly.GetManifestResourceNames();

    foreach (string name in names)

    {

    Stream s = assembly.GetManifestResourceStream(name);

    FileStream fs = new FileStream(name, FileMode.Create);

    BinaryWriter writer = new BinaryWriter(fs);

    byte[] buffer = new byte[s.Length];

    s.Read(buffer, 0, (int)s.Length);

    fs.Write(buffer, 0, (int)s.Length);

    fs.Close();

    s.Close();

    }

     

     

    Wednesday, March 12, 2008 11:24 AM

  • Thanks Philip .. i've now got a fair idea to make it work ...
    Your post indeed helped me in every way

    Thanks
    Srivatsa

    Thursday, March 13, 2008 9:27 AM
  •  

    I happened to stumble on this a couple of weeks ago. It's a pretty simple tool to unify a set of resource files through a web interface. The source code is downloadable and you can pop it into your visual studio solution as a separate website.  FYI it uses AJAX, so you may need to download the AJAX extensions.

    http://blog.lavablast.com/post/2008/02/RESX-file-Web-Editor.aspx

     

    Dave

    http://boatsinamerica.com

     

    Friday, March 14, 2008 3:39 PM