Can I modify the content of an embedded resource (text/xml file) in a .NET application

你离开我真会死。 提交于 2019-11-28 05:08:17

问题


The title is pretty much the question :-)

I've embedded an xml file and a txt file as resources in my .NET app. Am still debugging other things, so cannot run and test this.

So just asking, would I be able to modify these files at runtime, after deployment?


回答1:


Nope. An embedded resource is a set of bytes in the assembly.

Its like trying to modify the code in your assembly, after compiling.

This would be doubly bad if your assembly has been signed.

If you're trying to swap resources in and out, you can move your resources into a separate (satellite) assembly, and swap that assembly at deployment time.

What are you trying to achieve?




回答2:


No, you can't change embedded resources.

You might want to consider copying the resource out to disk on start up, if it doesn't already exist, but using an existing file if it's already there (in which case it may have been modified).



来源:https://stackoverflow.com/questions/1038795/can-i-modify-the-content-of-an-embedded-resource-text-xml-file-in-a-net-appli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!