2011-11-15 2 views
1

나는 모바일에서도 모든 Windows 버전에서 실행할 수있는 응용 프로그램을 만들고 있으며 실행 파일의 현재 디렉토리를 얻으려고합니다. 문제는 내가 다음 코드를 사용하는 경우, 그것은 윈도우 모바일에서 컴파일되지 않는다는 것입니다 :모든 Windows 버전에서 C#의 현재 디렉토리를 얻는 방법은 무엇입니까?

string currentDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); 

을 그리고 나는이 코드를 사용하는 경우, 내가 좋아하는 뭔가가 나타납니다 파일 : \의 C : \ XXX

string currentDirectory = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); 

는 있지만, 나는 루트 드라이브를 얻을 필요하고,이 코드는 윈도우 모바일에서 컴파일되지 않습니다 :

String rootPath = Path.GetPathRoot(Environment.SystemDirectory); 

누구든지 애플리케이션의 현재 디렉토리와 모바일의 모든 Windows 버전에 대한 루트 경로를 얻는 방법을 알고 있습니까?

+0

Windows Mobile에는 현재 디렉터리의 개념이 없습니다. 귀하의 응용 프로그램은 winMain() 함수에서 argv [0]로부터 EXE의 위치를 ​​얻을 수 있습니다. – BitBank

답변

2

이 줄에 뭔가가 있습니까?

var folder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) 
관련 문제