Resource 파일 경로 및 파일 이름 가져오기 (C# Winform)

2020. 10. 26. 17:30C#

728x90
반응형

특정 xxx.exe 프로그램을 통해 cmd로 명령 및 option을 날리기 위해

내장으로 실행하기 위한 EXE 프로그램을 Resource에 넣어두고

경로를 받아서 실행 하고자 하여 경로를 얻어와야 했다.



/// <summary>
/// Get the Project of Resource file from path 
/// </summary>
/// <returns></returns>
private string GetResourceFileName()
{
    // My Project Resource에 있는 파일의 Full Path를 가져오는 코드 
    String strAppPath = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
    String strFilePath = Path.Combine(strAppPath, "Resources");
    String strFullFilename = Path.Combine(strFilePath, "test.exe");

    return strFullFilename == "" ? "" : strFullFilename;

}

 

728x90
반응형