WinForm 응용프로그램의 실행 파일 경로는 System.Windows.Forms 네임스페이스에 있는 Application.StartupPath 프로퍼티를 참조하면 쉽게 구할 수 있다.
using System.Windows.Forms;
...
string path = Application.StartupPath;
using System.Reflection;
...
string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
Assembly.GetEntryAssembly().Location MSDN 설명을 보면 클래스 라이브러리 즉, 관리되는 코드를 관리되지 않는 코드에서 호출할 경우 null을 리턴한다고 나와있다. 이것만 주의해 주면 되겠다.
댓글 없음:
댓글 쓰기