본문 바로가기
프로그래밍 _공부자료./C#

C# .xml 파일 실행파일 경로 가져오는법

by 대구부자 2024. 7. 31.
반응형
string currentDir = ProcessExecutor.GetCurrentExePath();
string xmlFile = System.IO.Path.Combine(currentDir, "SettingFile.xml");
XmlDocument doc = new XmlDocument();
doc.Load(xmlFile);

// Application 노드 찾기
XmlNode appNode = doc.SelectSingleNode("//Application");

// Setting 노드에서 필요한 값 추출
string programPath = appNode.SelectSingleNode("Setting").InnerText;
string fullProgramPath = System.IO.Path.Combine(currentDir, programPath);

// 프로세스 시작 정보 설정
ProcessStartInfo startInfo = new ProcessStartInfo(fullProgramPath);
startInfo.UseShellExecute = false;

// 프로세스 실행
System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo); 
fullPath 가져오기

 

 

.xml파일 노드 찾는 가장 쉬운방법

반응형

'프로그래밍 _공부자료. > C#' 카테고리의 다른 글

C# wpf 오류 알림 모듈화  (0) 2024.07.23
C# 로그 클래스  (0) 2024.07.23
C# ATM 기능 만들기  (0) 2024.06.28

댓글