C#中:导入/导出设置到/从一个文件 [英] C#: Import/Export Settings into/from a File

查看:130
本文介绍了C#中:导入/导出设置到/从一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是从一个app导入/导出应用程序内部设置到文件的最好方法是什么?

What's the best way to import/export app internal settings into a file from within an app?

我有Settings.settings文件,WinForm的用户界面绑在设置文件,我想导入/导出设置,类似于Visual Studio的导入/导出设置功能。

I have the Settings.settings file, winform UI tied to the settings file, and I want to import/export settings, similar to Visual Studio Import/Export Settings feature.

推荐答案

如果您使用的是Settings.settings文件,它保存到配置文件。通过更新设置后,调用YourNamespace.Properties.Settings.Save(),它们将被保存到配置文件。

If you are using the Settings.settings file, it's saving to the config file. By calling YourNamespace.Properties.Settings.Save() after updating your settings, they will be saved to the config files.

不过,我不知道你所说的意思是多套设置。如果设置是由用户设置的,每个用户将有它自己的一组设置。如果您有多个组设置为一个用户,你可能不应该使用.settings文件;相反,你需要使用一个数据库。

However, I have no idea what you mean by "multiple sets of settings." If the settings are user settings, each user will have its own set of settings. If you are having multiple sets of settings for a single user, you probably should not use the .settings files; instead you'll want to use a database.

这篇关于C#中:导入/导出设置到/从一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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