Как получить Список <строка> набор значений от app.config в WPF?

Попробуйте опцию -xx:-useperfdata

JVM больше информации

, следующее могло бы быть полезным, который является из ссылки https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html

-XX:+UsePerfData

    Enables the perfdata feature. This option is enabled by default
    to allow JVM monitoring and performance testing. Disabling it 
    suppresses the creation of the hsperfdata_userid directories. 
    To disable the perfdata feature, specify -XX:-UsePerfData.

68
задан Manfred Radlwimmer 30 January 2017 в 07:15
поделиться

2 ответа

Вы можете создать свой собственный настраиваемый раздел конфигурации в файле app.config. Существует довольно много нескольких руководств вокруг , которые помогут вам начать работу. В конечном итоге у вас может быть что-то вроде этого:

<configSections>
    <section name="backupDirectories" type="TestReadMultipler2343.BackupDirectoriesSection, TestReadMultipler2343" />
  </configSections>

<backupDirectories>
   <directory location="C:\test1" />
   <directory location="C:\test2" />
   <directory location="C:\test3" />
</backupDirectories>

В дополнение к ответу Ричарда, это C #, который вы можете использовать с его образцом конфигурации:

using System.Collections.Generic;
using System.Configuration;
using System.Xml;

namespace TestReadMultipler2343
{
    public class BackupDirectoriesSection : IConfigurationSectionHandler
    {
        public object Create(object parent, object configContext, XmlNode section)
        {
            List<directory> myConfigObject = new List<directory>();

            foreach (XmlNode childNode in section.ChildNodes)
            {
                foreach (XmlAttribute attrib in childNode.Attributes)
                {
                    myConfigObject.Add(new directory() { location = attrib.Value });
                }
            }
            return myConfigObject;
        }
    }

    public class directory
    {
        public string location { get; set; }
    }
}

Затем вы можете получить доступ к разделу конфигурации backupDirectories следующим образом:

List<directory> dirs = ConfigurationManager.GetSection("backupDirectories") as List<directory>;
118
ответ дан 24 November 2019 в 13:57
поделиться

Их можно разделить точкой с запятой в одном значении, например

App.config

<add key="paths" value="C:\test1;C:\test2;C:\test3" />

C #

var paths = new List<string>(ConfigurationManager.AppSettings["paths"].Split(new char[] { ';' }));
139
ответ дан 24 November 2019 в 13:57
поделиться
Другие вопросы по тегам:

Похожие вопросы: