Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 加载应用程序选项的建议_C#_.net_Configuration_Persistence - Fatal编程技术网

C# 加载应用程序选项的建议

C# 加载应用程序选项的建议,c#,.net,configuration,persistence,C#,.net,Configuration,Persistence,我想创建一个WinForms应用程序。 此应用程序将有许多可配置的选项保存在数据库中,因此它们可以在执行过程中保持不变(例如打印设置、设计选项等) 为避免频繁访问数据库,您建议采用什么方法加载这些选项 谢谢 存在一些问题,保存在数据库中的设置将由所有用户共享。在这种情况下,您必须考虑为每个用户设置。更好的选择是保存在可以加密和使用的本地配置文件中。如果需要在用户之间共享任何内容,则可以将db用于该特定选项。您可以在应用程序加载之前加载这些选项,并通过对象访问它 通过向用户显示进度,可以在启动屏幕

我想创建一个WinForms应用程序。 此应用程序将有许多可配置的选项保存在数据库中,因此它们可以在执行过程中保持不变(例如打印设置、设计选项等)

为避免频繁访问数据库,您建议采用什么方法加载这些选项


谢谢

存在一些问题,保存在数据库中的设置将由所有用户共享。在这种情况下,您必须考虑为每个用户设置。更好的选择是保存在可以加密和使用的本地配置文件中。如果需要在用户之间共享任何内容,则可以将db用于该特定选项。您可以在应用程序加载之前加载这些选项,并通过对象访问它


通过向用户显示进度,可以在启动屏幕中执行这些数据库获取操作

如果it安全性不重要,还可以将设置保存在表单读取的xml文件中。您可以有一个类来加载所需的属性

这是相当粗糙的,但我有类似的东西,工作得很好,很容易设置


干杯

您在读取数据库时遇到问题吗?你的问题不是很清楚。
[Serializable()]
public class Defaults
{
    public string Description { get; set; }
    public double Tolerance { get; set; }
    public string Units { get; set; }
 }

internal class FormDefaults
{
public void LoadSettings()
    {
      string kfileString = @"C:\Default_Settings.xml";

      var q = from el in XElement.Load(kfileString).Elements()
                select new FormDefault()
                {
                    Description = el.Element("InstrumentDescription").Value,
                    Tolerance = Double.Parse(el.Element("InstrumentMassTolerance").Value),
                    Units = el.Element("InstrumentMassUnits").Value,

                };
        }
    }
}