2012-11-02 5 views
2

주 응용 프로그램 JIMS.exe의보고 폴더 안에있는 JIMS.Printing.dll이라는 DLL이 있습니다. JIMS.exe.Net에서 실제 dll 경로 가져 오기

를 실행보고의 내부 JIMS.Printing.dll 코드 내부의 템플릿 폴더 내부의 파일을 호출 할 때

하지만 오류를 얻고있다

JIMS.exe 
--------->Reporting 
------------------->JIMS.Printing.dll 
------------------->Templates 
-----------------------------> Files 

코드 :

string _templatePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(JIMS.Printing.PrintInvoice)).Location), "Templates"); 

코드 JIMS.Printing.dll

JIMS.exe는 JIMS.exe Path \ Templates \ file, 내의 파일을 찾고 있습니다. 실제로 파일은 JIMS.Printing.dll에 있습니다. 경로 \ 템플릿 \ 파일

+0

무엇이 오류입니까? 귀하의 질문은 무엇인가? – prprcupofcoffee

답변

7

당신은 사용할 수 있습니다

Assembly.GetExecutingAssembly().Location 

당신에게 어셈블리 실행의 경로를 줄 것이다 다음 사용

System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) 

포함 폴더를 제공합니다.

+0

이 답변을 확인할 수도 있습니다. http://stackoverflow.com/a/283917/1306012 –

2

당신이 시도 할 수 있습니다 : -

string path1= System.Reflection.Assembly.GetAssembly(typeof(DaoTests)).Location; 

string directory= Path.GetDirectoryName(path1); 
+0

이것은 내가 사용하고있는 것입니다. 작동하지 않습니다. –