问题
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?
Thanks
回答1:
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#
回答2:
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.
回答3:
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
回答4:
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.
来源:https://stackoverflow.com/questions/13218777/can-i-edit-resource-file-at-runtime