2011-05-10 2 views
2

내 exe의 현재 작업 디렉토리를 가져오고 싶습니다. Directory.GetCurrentDirectory() 응용 프로그램을 배포 할 때 exe의 작업 디렉토리가 반환되지 않습니다.릴리스 모드에서 현재 작업 디렉토리를 가져 오지 못합니까?

현재 작업 디렉토리를 얻는 방법은 무엇입니까?

+2

나는 기능이 고장 의심보십시오. 따라서 작업 디렉토리 *는 어떤 이유로 든 예상 한 것이 아닙니다. 어떻게 응용 프로그램을 배포하고 있습니까? 시작되는 방법, 현재 디렉토리가 어떤 디렉토리입니까? 그리고 실제로 디렉토리는 무엇입니까? –

답변

5

안녕
AppDomain.CurrentDomain.BaseDirectory

+0

+1, 해당 속성이 있는지 여부를 알 수 없습니다. – jgauffin

+0

@jgauffin : Environment.CurrentDirectory를 사용하여 응용 프로그램의 작업 디렉토리를 얻었으며 Dev 환경에서 작동하는 것처럼 보였습니다.하지만 창 서비스를 만들고 intalled하면 'Environment.CurrentDirectory'가 system32의 경로를 반환했습니다. 그 이유는 내가 안전하다고 생각하는 AppDomain.CurrentDomain.BaseDirectory를 사용하기 시작한 이유입니다. – wizzardz

+0

'Environment.CurrentDirectory'는 응용 프로그램이 시작된 디렉토리입니다. 모든 응용 프로그램은 어디서나 시작할 수 있습니다. – jgauffin

3

시도 :

var path = Environment.CurrentDirectory

나 :

var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); 
+1

첫 번째 것은 OP가 시도한 것과 동일합니다. 다음을 참조하십시오. http://stackoverflow.com/questions/1164756/what-is-the-difference-between-environment-currentdirectory-and-directory-getcurr –

+0

@ Daniel Hilgarth : 고마워, 그걸 몰랐어. – jgauffin

관련 문제