在console.application中保存功能 [英] Save function in console.application

查看:52
本文介绍了在console.application中保存功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试使用console.application创建一个简单的客户列表。我可以知道在关闭程序后如何保存数据?例如,我执行了一次程序,它提示我输入客户名称(Alex)并显示客户名称的完整列表。下次我再次执行程序时,它会提示我再次输入客户名称(Betty),但这次显示屏显示第一个客户名称,Alex跟随Betty。



简而言之,当我关闭程序时如何保存某些数据并在我再次执行程序时重新调用它。谢谢。



我尝试了什么:



试图使用My.Computer.FileSystem.WriteAllText和ReadAllText命令但实现了ReadAllText命令总是需要指定要读取的文件的位置。

Hello, i'm attempting to create a simple customer list with console.application. May I know how can i save the data after i close the program? For example, I executed the program once and it prompts me to enter a customer name(Alex) and display the full list of customer name. The next time i execute the program again, it prompts me to enter a customer name again(Betty) but this time the display shows the first customer name,Alex followed by Betty.

To put it short, how can i save a certain data when i close the program and recall it back when i execute the program again. Thank you.

What I have tried:

tried to use My.Computer.FileSystem.WriteAllText and ReadAllText command but realized ReadAllText command always need to specify the location of the file to read.

推荐答案

你走在正确的轨道上。您需要做的就是为数据创建容器 - 数据库。根据您要实现的目标,您可以使用平面文件(文本文件,xml文件),简单数据库(MS Access数据库,SQLite)或服务器站点数据库(MS SQL Server,PostgreSQL等)。如果要使用简单的数据库模型,则必须确定数据的存储位置。我建议你阅读:我应该在哪里存储我的数据? [ ^ ]。



此刻,我建议您使用 XmlSerialization [ ^ ]序列化过程是将对象转换为易于传输的形式的过程。

XML序列化和反序列化:第1部分 [ ^ ]

XML序列化和反序列化:第2部分 [ ^ ]

自定义类集合序列化和反序列化的完整示例 [ ^ ]
You're on the right track. All you need to do is to create container for data - a database. Depending on what you want to achieve, you can use flat file (text file, xml file), simple database (MS Access database, SQLite) or server-site database (MS SQL Server, PostgreSQL, etc.). If you want to use simple database model, you have to decide where your data should be stored. I'd suggest to read this: Where should I store my data?[^].

At this moment, i suggest you to use XmlSerialization[^] as the process of serialization is the process of converting an object into a form that can be readily transported.
XML Serialization and Deserialization: Part-1[^]
XML Serialization and Deserialization: Part-2[^]
A Complete Sample of Custom Class Collection Serialization and Deserialization[^]


这篇关于在console.application中保存功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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