5

I have a WCF service, it response with JSON. I need to create a language file, which I can edit on production server. no problem if I will need to recycle App pool.

I was about to use Resource file, but I was worry that it is not editable by end user. I don't need to edit it pragmatically, the end user will edit it by opening the file in notepad without recompiling the application.

What do you suggest?

cigien
  • 57,834
  • 11
  • 73
  • 112
Costa
  • 3,897
  • 13
  • 48
  • 81
  • Resource files are essentially XML files under the hood, so it's easy enough to create one at runtime. If you are editing said file at runtime, you need to make sure no other processes are writing to the file too, otherwise you'll get an exception. – Mathew Thompson Nov 04 '12 at 13:11

4 Answers4

5

Yes you can using the ResXResourceWriter class.

If you need to generate the Designer.cs file as well see this question Programmatically generate Designer.cs for resx file (ResXResourceWriter/ResXResourceReader)

If you need to modify the existing resx files see this question Modifying .resx file in c#

Community
  • 1
  • 1
Stefan P.
  • 9,489
  • 6
  • 29
  • 43
  • I don't need to edit it pragmatically, the end user will edit it by opening the file in notepad – Costa Nov 04 '12 at 13:19
1

According to MSDN, you can add new resource at runtime:

You can incrementally add resources for new cultures after you have deployed an application. Because subsequent development of culture-specific resources can require a significant amount of time, this allows you to release your main application first, and deliver culture-specific resources at a later date.

http://msdn.microsoft.com/en-us/library/sb6a8618%28v=vs.110%29.aspx

I think editing current resource will also work.

  • While this is true, this works with compiled resources only. If you want to do the same with .resx files and access them the same way as by `ResourceManager` you can use [this](https://github.com/koszeggy/KGySoft.CoreLibraries#dynamic-resource-management) library (disclaimer: written by me). For example, [`ResXResourceManager`](https://docs.kgysoft.net/corelibraries/html/T_KGySoft_Resources_ResXResourceManager.htm) is compatible with `ResourceManager` but works on .resx files and has read-write capabilities. [NuGet](https://www.nuget.org/packages/KGySoft.CoreLibraries) – György Kőszeg Feb 13 '23 at 16:48
0

Your users should be able to edit the files with no problems, the resource files are XML files that can be opened in notepad or any text editor, they could even open it in Excel and get multiple columns that they can easily edit.

This will require recycling your App pool but you're open to that.

[edit] You don't need to be recompile as I mentioned before if your resource files are marked as content, but your App pool will be recycled to pick up changes

kabaros
  • 5,083
  • 2
  • 22
  • 35
0

I am not sure but it seems that user can't edit resource file using a notepad at runtime, and the application should rebuild in order changes takes effect.

Setting file with user scope can do the job.

Costa
  • 3,897
  • 13
  • 48
  • 81