如何在应用程序中保存数据以方便部署? [英] How to save data in my application for easy deployment?

查看:160
本文介绍了如何在应用程序中保存数据以方便部署?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用WinForms创建一个应用程序,任何只需要安装.NET的人都可以安装该应用程序.没有像SQL Server这样的先决条件.我必须使用哪种方法才能完成此任务?像将数据保存在XML文件中一样?
任何链接,示例,建议或指导都将不胜感激.

I am trying to create an application using WinForms that can be installed by anyone requiring only .NET installed. No pre-requisites like SQL Server. What method do I have to use in order for that to accomplish? Like save data in a XML file ?
Any links, examples, suggestion or direction will be appreciated.

推荐答案

您可以使用SQLCE数据库-驱动程序等完全包含在.NET框架中,因此没有需要其他安装.
请参阅 SqlCEConnection [ ^ ]
就用途而言,它与SQL Server相同,只是它是单用户而不是多用户,并且不支持存储过程或命令链.
You could use an SQLCE database - the drivers etc are fully included in the .NET framework, so no additional installation is required.
See SqlCEConnection[^]
It''s the same as SQL Server as far as usage goes, except it is single user rather than multi user, and does not support stored procedures or command chaining.


这取决于如何您拥有许多数据,以及如何构建它们.如果您没有太多的数据,那么XML是相当不错的,而且重量轻.一种几乎自动的选择是使用数据合同.

请参阅 http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

另请参阅我过去的解决方案:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [反序列化json字符串数组 [^ ].

最佳,最干净的部署称为"x-copy安装":将输出目录的内容复制到用户的计算机,它便开始工作而没有任何麻烦.要进行部署,只需将其压缩.首先考虑这种方式,尤其是在您的应用程序很简单的情况下.如果将数据文件放在项目中,它也将位于输出目录中.另外,也可以使用.xres资源将文件嵌入到您的汇编可执行文件中.

—SA
It depends on how much data do you have and how do you structure it. XML is quite good and light weight if you have not too much data. One nearly automatic option is using Data Contract.

See http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

See also my past solutions:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating a property files...[^].

That was about XML, but you also can use JSON, see deseralize a json string array[^].

Best and cleanest deployment is so called "x-copy installation": you copy the content of your output directory to a user''s computer and it start working without any hassles. For deployment, just zip it. Consider this way first, especially if your application is simple. Your data file will come in your output directory as well, if you put it in the project. Alternatively, embed the file(s) in your assemblt exectutable(s) using .xres resources.

—SA


这篇关于如何在应用程序中保存数据以方便部署?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆