从外部应用程序读取我的设置 [英] Reading my.settings from outside application

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

问题描述

谢谢.

但是,我认为我对自己的解释不够充分.我使用.config文件为用户名和密码之类的设置创建存储.我提供的用户名和密码设置为空字符串('').例如:
收合|复制代码

<  设置    ="  用户名"  serializeAs    String" > 
      <     > 


当用户安装该应用程序时,他们创建其用户名和密码,该用户名和密码保存在my.settings.username;中.我的设置保存.

我的(错误的)假设是,如果我打开.config文件(如您建议的那样使用记事本),则可以看到新的用户名.但是,.config文件仍然保留为:
收合|复制代码

<  设置    ="  用户名"  serializeAs    String" > 
      <     > 

即使应用程序使用来显示其值
收合|复制代码

Form1.username.text =我的设置.用户名

如果用户选择重新调用它.

我对此完全满意.这就是为什么我问:因此,是否可以安全地存储其他用户设置(例如密码)?

我意识到,如果您在其中存储了任何应用程序信息,那么读取注册表是多么容易.到现在为止,我不知道是否存在某种无需打开数据库即可读取该用户名的方法,例如,当用户取消选中记住我"后,他们忘记了它是什么.我在千里之外,我不希望他们在失去登录凭据时与数据库混为一谈.

如果我将其存储在注册表中,则将使用regedit来获取它,而无需访问数据库.如果我将其存储在my.settings中,是否已给出上面的说明来阅读它?

我希望这更清楚


.

解决方案

1)设置是XML格式的文本文件,您可以使用记事本阅读它,请参见此处:
http://msdn.microsoft.com/en-us/library/ms379611%28v = vs.80%29.aspx [ ^ ]

2)像这样在客户端上保存敏感信息是一个坏主意,如果您正在处理客户端/服务器类型的应用程序而不是独立的应用程序,则最好将它们存储在数据库中的服务器上.

Thanks.

I however think I did not explain myself well enough. I use the .config file to create a store for settings like username and password. I deliver the application with username and password set as empty string (''). eg:
Collapse | Copy Code

<setting name="Username" serializeAs="String">
      <value />


When the user installs the application, they create their username and password which is saved in my.settings.username; my.settings.save.

My (wrong) assumptions was that if I opened up the .config file (using notepad as you have suggested) I could see the new username. However, the .config file still remains as:
Collapse | Copy Code

<setting name="Username" serializeAs="String">
      <value />

even though the application displays its value using
Collapse | Copy Code

Form1.username.text = my.settings.username

if user chose to recall it.

I am totally fine with that; and that is why I asked: is it therefore a safe place to store other user settings like password?

I realised how easy it is to read the registry if you stored any application information there. Upto now, I dont know if there is some way of reading this username without opening up the database, say when the user unchecked 'remember me' and then they forgot what it was. I am miles away and I dont want them to meddle with the database when they lose their login credentials.

If I stored that in a the registry I will use regedit to get it without going to the database. If I stored it in my.settings is there a way of reading it having given the explanation above?

I hope this is clearer


.

解决方案

1) The settings is a text file in XML format and you can read it with notepad, see here :
http://msdn.microsoft.com/en-us/library/ms379611%28v=vs.80%29.aspx[^]

2) Its a bad idea to save sensitive information on the client like this, it''s much better to store them on your server in a database if you are doing client/server type of application as opposed to a standalone.


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

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