应用程序设置 [英] Application Settings

查看:79
本文介绍了应用程序设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发一个应用程序,需要跟踪多个条目并将它们保存在下一次​​应用程序中.简而言之,我想为我的应用程序设置一个设置部分.现在,我一直在尝试其他事情,例如配置文件"条目和app.config.
任何人都可以通过向我推荐一些好的教程来指导我,因为我已经在互联网上搜索了,但没有找到满足我需求的东西.
问候,
法鲁克·贾维德

从OP的答案移到:
我认为,我在解释这个问题时可能犯了一个小错误.我要做的是保存一些有关用户的信息,这些信息他可以随时更改.
例如,我想保存客户端的默认用户名和密码,但是从他的多个帐户中,用户可以选择其中的任何一个,这样,新条目将替换之前的条目.
非常感谢您的支持.

Hi,
I am developing an application where I need to keep track of multiple entries and keep them saved in the application for the next time. In short, I want to make a settings section for my application. Now, I have been trying out different things like Config File entries and app.config.
Can anyone guide me by suggesting me some good tutorial because I have already searched the internet but have found nothing to fulfill my demand.
Regards,
Farrukh Javeid

Moved from Answer by OP:
I think, I might have made a little mistake in explaining the problem. What I want to do is to save some information about the user that he can alter at anytime.
For example, I want to save the default username and password of the client but out of his muliple accounts, the user can select any of them and from so on that new entry will replace the previous one.
Thank you very much for your support friends.

推荐答案

很简单:
1)在解决方案资源管理器中打开项目属性",然后双击"Settings.settings"
2)在生成的网格中,将名称"更改为"MySetting",然后将值"设置为默认值".分别将类型"和范围"保留为字符串"和用户".
3)保存并关闭设置窗口.
4)阅读设置:
It''s easy:
1) Open your projects Properties in the solution explorer, and double click on "Settings.settings"
2) In the resulting grid, change the Name to "MySetting", and set the Value to "Defaulted value". Leave Type and Scope as "string" and "User" respectively.
3) Save and close the settings window.
4) To read your setting:
string s = Properties.Settings.Default.MySetting;

5)编写设置:

5) To write your setting:

Properties.Settings.Default.MySetting = "My new setting value";
Properties.Settings.Default.Save();


替代解决方案:
试试SQLite
http://sqlite.phxsoftware.com/ [ ^ ]

我想您会发现一个适合您需求的轻量级数据库.使用它来满足您的本地存储需求.

问候
Espen Harlinn
An alternative solution:
Try SQLite
http://sqlite.phxsoftware.com/[^]

A lightweight database I think you will find suitable for your requirements. Use it for your local storage requirements.

Regards
Espen Harlinn


如果这很简单,请使用已经建议的方法.如果您需要一些复杂的值,请使用ConfigurationSection类创建自己的自定义配置部分.
If it is something simple, use what is already suggested. If you are after some complex set of values, use ConfigurationSection class to create your own custom configuration sections.


这篇关于应用程序设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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