어서 노를 저어라!

2009/05/18

c# 프로그램 실행 디렉토리 가져오기

http://www.csharp-examples.net/get-application-directory/

1. 윈도우 폼 디렉토리(exe)
 Path
.GetDirectoryName(Application.ExecutablePath);
 Application.StartupPath;   // 이상태로는 위와 같은 결과를 보인다.
— Application 을 사용하려면 System.Windows.Forms 레퍼런스를 첨부 시켜줘야한다.

2. 로딩된 어셈디렉토리(exe,dll)
 Path
.GetDirectoryName(Assembly.GetAssembly(typeof(MyClass)).CodeBase);

3. Another
 System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
 주의- file://c/winnt/…/filename.exe 형식으로 리턴값이 주어진다.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: