简体   繁体   English

c# 访问自定义设置文件

[英]c# Accessing custom Settings File

So I went in to the project and right click > Add and created a new Config.settings file and Login.settings file.所以我进入项目并右键单击>添加并创建了一个新的 Config.settings 文件和 Login.settings 文件。

I then added a couple of inputs in each of those settings files.然后我在每个设置文件中添加了几个输入。

How do go about accessing the settings values in those settings files?如何访问这些设置文件中的设置值?

I tried Properties.Default... but then it seems to not recognize Properties class as it shows a curly red underline in its name.我尝试了Properties.Default...但它似乎无法识别Properties类,因为它的名称中显示了一个红色的卷曲下划线。

Do I have to import some name space?我必须导入一些命名空间吗?

I then try adding a new file called "Setting.settings" file and its still the same.然后我尝试添加一个名为“Setting.settings”文件的新文件,它仍然相同。 I clean and rebuilt my project too.我也清理并重建了我的项目。

Try right clicking on .settings file and selecting run custom tool option.尝试右键单击 .settings 文件并选择运行自定义工具选项。

Also, sometimes it helps when you manually remove bin and obj files from project.此外,有时当您从项目中手动删除 bin 和 obj 文件时它会有所帮助。 Finally, close the solution and open again.最后,关闭解决方案并再次打开。

For user overrides and how settings are working refer to microsoft docs: https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/using-application-settings-and-user-settings有关用户覆盖以及设置如何工作,请参阅 Microsoft 文档: https : //docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/using-application-settings-and-user-settings

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM