loading external file on the fly RRS feed

  • Question

  • User-1624111774 posted
    Hi ,
    i would like to load file while the application is running , something like
    the file is located somewhere in my application
    can i do this? how i get values from the files after i loaded it?

    Thank you
    Tuesday, May 16, 2006 1:11 PM

All replies

  • User-1624456073 posted
    If you have a .resx file you want to load, then you can use the ResxResourceReader.If you want to load a .resource file, you can use the ResourceReader

    And finally, my favorite, if you want to load a resource that's located within an assembly, you can do:

    // Assumes the resource called Strings is located within the assembly MyResources.

    Or use Assembly.LoadFile, if needed
    Assembly assembly = Assembly.Load("MyResources, Version=, Culture=neutral, PublicKeyToken=null");

    string baseName = "MyResources.Strings";
    ResourceManager manager = new ResourceManager(baseName, assembly);

    // now, to get the string resource with key 'String1'
    string str = manager.GetString("String1");

    // or the image with key "Image1"
    Image img = manager.GetObject("Image1") as Bitmap;

    .Net  also comes with a tool to auto-generate a type-safe wrapper class for resource files. Visual Studio does that automatically for .resx files added to a project :)
    Thursday, May 18, 2006 3:06 PM