是否有 web.config 等同于 UWP 应用程序开发?

Is there a web.config equivalent for UWP App development?

在 Web 开发中,我们有 web.config,我可以在其中为每个客户端分别手动配置一些应用程序设置。 UWP 应用程序是否有类似的东西[我正在开发 Windows UWP 应用程序。]

希望对你有所帮助。

您可以添加 appsettings.json 文件 例如:-

appsettings.json

{
  "key1": "value1",
  "key2": "value2"
}

确保 appsettings.json 文件 属性 将 "Copy To Output Directory" 设置为 "Copy always"。

像这样从 appsettings.json 文件中查找值-

var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
IConfiguration configuration = builder.Build();
string GetValue1 = configuration.GetSection("key1").Value;
string GetValue2 = configuration.GetSection("key2").Value;

谢谢!!!