C# 작업 프로필 (1)
1133 단어 config
질의 구성 파일
ConfigurationManager를 사용합니다.AppSettions는 키에 따라 해당하는value 가져오기
string value=ConfigurationManager.AppSettings["test"]; //test key
프로파일 업데이트, 추가
public static bool SetConfig(string key, string value)
{
try
{
Configuration conf = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (!conf.AppSettings.Settings.AllKeys.Contains(key)) // key
{
conf.AppSettings.Settings.Add(key, value); //
}
else
{
conf.AppSettings.Settings[key].Value = value; //
conf.Save();
return true;
}
}
catch
{
return false;
}
}
요약:
또한 프로파일 작업은 XmlDocument을 사용하여 수행할 수 있습니다.다음에 총결산을 하겠습니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Windows 10의 Docker: 사용자 지정 구성 파일로 mysql:8.0.30-debian 실행.사용자 지정 구성 파일 E:\mysql-config\mysql-docker.cnf를 사용하여 Windows 10에서 공식 mysql:8.0.30-debian 이미지를 실행하는 데 필요한 단계입니다. 내 Windows...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.