为下次启动存储字符串数组! [英] Storing a string array for the next startup!

查看:87
本文介绍了为下次启动存储字符串数组!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在程序中存储一个字符串数组,以便每次程序启动时都可以检索它.
除了将数组存储在文本文件中之外,还有其他方法吗???

谢谢,

I need to store a string array in my program so it can be retrieved every time the program starts...
is there any method other than storing the array in a text file???

thanks,

推荐答案

您可以使用BinaryFormatter序列化包含数组的对象.
这将创建对象的二进制映像,您可以将其写入二进制文件.

MSDN BinaryFormatter
You can use the BinaryFormatter to serialize an object containing your array.
This will create a binary image of your object which you can write to a binary file.

MSDN BinaryFormatter


如果数组中的值是固定的,并且它是一个小的实用程序,则可以将其作为数组变量存储在代码本身中.否则,如果您知道它可能会被用户修改,则可以选择一个单独的文本文件,一个资源文件(.resx)或作为配置数据存储在DB中.
If the values in the array is fixed and it''s a small utility program you can store it in the code itself as an array variable. Otherwise if you know it may get modified by the user you may choose either a separate text file, a resource file (.resx) or store as configuration data in the DB.


ab)为此使用Windows注册表
you can (ab)use the windows registry for this


这篇关于为下次启动存储字符串数组!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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