파일 이름을 쓰고 싶은 콘솔 응용 프로그램이 있습니다.
Process.Start("blah.bat");
일반적으로, 나는 파일의 이름을 기록하여 Windows 응용 프로그램에서 그런 일을했을 'blah.bat'
에 설정 에서 파일 속성을 .
그러나 여기서는 설정 파일을 찾지 못했고 동일한 목적으로 app.config 를 추가했습니다 .
여기에 app.config에 무엇을 써야할지 모르겠습니다. 그러면 Windows Forms 에서와 비슷한 결과를 얻을 수 있습니다.
예 : Windows 양식에서. Process.Start(Properties.Settings.Default.BatchFile);
어디 BatchFile
속성의 설정 파일의 문자열입니다.
답변
System.Configuration
프로젝트에서에 참조를 추가 한 후 다음 을 수행 할 수 있습니다 .
using System.Configuration;
그때
string sValue = ConfigurationManager.AppSettings["BatchFile"];
다음과 같은 app.config
파일로 :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="BatchFile" value="blah.bat" />
</appSettings>
</configuration>
답변
답변
이것을 사용하십시오
System.Configuration.ConfigurationSettings.AppSettings.Get("Keyname")