문제

WPF 응용 프로그램에서 클릭합니다 설정 .SETTINGS 솔루션 탐색기에서 a StringCollection a 사용자 범위:

alt text

내 app.config에서 나는 그들이 거기에 저장된 것을 본다.

<userSettings>
    <TestSettings.Properties.Settings>
        <setting name="Paths" serializeAs="Xml">
            <value>
                <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                    <string>one</string>
                    <string>two</string>
                    <string>three</string>
                    <string>four</string>
                    <string>five</string>
                    <string>six</string>
                    <string>seven</string>
                </ArrayOfString>
            </value>
        </setting>
    </TestSettings.Properties.Settings>
</userSettings>

그럼 내가 내 응용 프로그램을 실행하십시오 그리고이 코드로 :

StringCollection paths = Properties.Settings.Default.Paths;

Properties.Settings.Default.Paths.Add("added in code");
Properties.Settings.Default.Save();

foreach (var path in paths)
{
    System.Console.WriteLine(path);
}

나에게 이것을 준다 산출:

one
two
three
four
five
six
seven
added in code

응용 프로그램을 다시 실행하십시오 그리고 그것은 나 에게이 출력을 제공합니다.

one
two
three
four
five
six
seven
added in code
added in code

그러나 나는 내 것을 본다 app.config 다시하고 여전히 있습니다 원래 값:

<userSettings>
    <TestSettings.Properties.Settings>
        <setting name="Paths" serializeAs="Xml">
            <value>
                <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                    <string>one</string>
                    <string>two</string>
                    <string>three</string>
                    <string>four</string>
                    <string>five</string>
                    <string>six</string>
                    <string>seven</string>
                </ArrayOfString>
            </value>
        </setting>
    </TestSettings.Properties.Settings>
</userSettings>

응용 프로그램에 의해 추가 된 값은 어디에 있습니까?

도움이 되었습니까?

해결책

사용자 범위를 선택 했으므로 각 사용자 프로필 디렉토리,보다 구체적으로 내부에서 저장됩니다. AppData 명명 된 파일의 사용자 프로필의 폴더 user.config.

전체 경로는 응용 프로그램에 따라 다릅니다.

로밍 프로파일이없는 Windows 7 및 Windows Forms Application이라는 Example.Settings.CustomClass 다음 폴더가 있습니다.

C:\Users\[user]\AppData\Local\Microsoft\Example.Settings.CustomCl_Url_3qoqzcgn1lbyw2zx3oz1o3rsw2anyjsn\1.0.0.0

또한 응용 프로그램의 버전을 고려하여 저장된 값과 저장된 값을 고려하여 저장됩니다. App.config 새 사용자에게 사용되는 기본값입니다.

다른 팁

나는 설정을 위해 Win 10을 찾고 있었다. 다른 사람이 알아야 할 경우 Microsoft의 하위 폴더에 저장되지 않습니다 (이전 답변 참조). 여기서 봐 :

C:\Users\[user]\AppData\Local\Example\Example...\1.0.0.0\
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top