locked
What should resource files be used for? RRS feed

  • Question

  • What should resource files be used for, ideally?

    I know, it seems as though I asked the question without searching it on the net first.  But that's not quite true.  I also realize that wpf may not be the best forum for the question, but I wanted to get an idea of what wpf application developers use resource files for? After all, these are compiled into the executable, so what have you - who have developed many applications in the past - put into resource files?



    MarcinMR

    Friday, March 18, 2016 7:49 PM

Answers

  • >>After all, these are compiled into the executable, so what have you - who have developed many applications in the past - put into resource files?

    For example images and icons that are used in the application. Or any other kind of file that you want to package into your assembly for convenience. You may have an existing image on a file that you want to display in your application, so you add it to your project as a resource to compile it into the assembly. This is very common. A resource can be accessed at runtime time using a Uri: https://msdn.microsoft.com/library/aa970069(v=vs.100).aspx.

    This is for example useful if you are developing a shared library that contains resources such as for example images. If you add a file as content, you will need to manually copy it the output folder of all applications but if you embed it in the assembly, you only need to reference the assembly as usual. This is more convenient.

    If you are referring to .resx files, they are used to localize an application. Please refer to the following page for more information and a downloadable sample: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/6bfb8d13-3a86-4c10-a632-bb20c99d0535/localization-in-wpf-using-resx-files-for-different-languages?forum=wpf

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    • Marked as answer by MarcinMR Sunday, March 20, 2016 10:00 PM
    Saturday, March 19, 2016 11:18 AM