Re-Embedding Sqlite Database file into the same Executable

最后都变了- 提交于 2019-12-02 07:22:30

问题


I'm Creating Win Form application ,I'm adding a Empty Sqlite Database file having Tables in it as embedded data source. on run time i extract Database file into application path and INSERT THE VALUES into the TABLE of that Database file. On Closing the application again i have to update or replace Database File into Executable. Is it possible ,if so how to do that.


回答1:


I'm not sure if I understand the question correctly. If you are trying to re-write to the same exe you are running this is NOT possible. Windows locks code files that are in use so that they can't change. Additionally, it is not advisable either, code and data should be separate.

If you are trying to update another resources executable (that is not currently running), I don't know how to do that programatically (See this thread here for more info How do I replace embedded resources in a .NET assembly programmatically?) but if your program has access to the Visual Studio Compiler tools (which it probably doesn't) you can disassemble and reassemble the executable. See here: http://fortheloveofcode.wordpress.com/2007/09/24/change-resources-inside-assembly/.




回答2:


Why not just store it in application folder? Or maybe user's AppData if you don't want to show it?



来源:https://stackoverflow.com/questions/6757457/re-embedding-sqlite-database-file-into-the-same-executable

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