[C#] 응용 프로그램에서 Config파일에서 사용자 지정 정보 저장 및 검색 (System.Configuration)
요구사항
-> Microsoft Windows
-> Visual C#
-> XML (Extensible Markup Language)
-> .NET 구성 파일
사용
응용 프로그램과 연결된 구성 파일에 응용 프로그램 설정을 저장할 수 있습니다. 구성 파일은 XML 형식으로 저장 됩니다.
. NET Framework 의 네임스페이스 및 네임 스페이스에는 런타임에 .NET 으용ㅇ 프로그램 구성 파일에서 정보를 검색하는 데 필용한 "System.Configuration" 클래스가 포함되어야 합니다.
1. Get Application Config
-> Key 값을 통해 App.config 값 호출
public string GetAppConfig(string key) { return ConfigurationManager.AppSettings[key]; } |
-> key 값을 이용한 값 호출.
appConfigration = new appConfig(); debugLog("Configuration : " + appConfigration.GetAppConfig(StartDateKey)); |
2. Set Application Config
-> Key 값을 통해 App.config 값 호출
public string SetAppConfig(string key, string value) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); KeyValueConfigurationCollection cfgCollection = config.AppSettings.Settings; cfgCollection.Remove(key); cfgCollection.Add(key, value); config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name); } |
'IT > 컴퓨터프로그램' 카테고리의 다른 글
[Python] FinanceDataReader 를 통한 주가 읽기 (0) | 2022.05.16 |
---|---|
[Python] 구글 트렌드(Google Trends PYTHON API) (0) | 2022.05.16 |
[프로그램] 임베디드 시스템 (Embedded System) (1) | 2022.05.16 |
[PYTHON] 숫자(초)을 시간으로 바꾸기 (0) | 2022.05.16 |
[PYTHON] 최상위 스크립트 환경 (0) | 2022.05.16 |