2

I have a dll named JIMS.Printing.dll which is placed inside the Reporting folder of the main application JIMS.exe.

But I am getting an error when calling some files inside the Templates folder inside JIMS.Printing.dll code inside of Reporting which running JIMS.exe

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

Code:

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

Code from JIMS.Printing.dll

JIMS.exe looking for Files inside JIMS.exe Path\Templates\file, But actually the file is in JIMS.Printing.dll Path\Templates\files

Kishore Kumar
  • 12,675
  • 27
  • 97
  • 154

2 Answers2

8

You can use:

Assembly.GetExecutingAssembly().Location

which will give you the path of the executing assembly then use:

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

which will give the containing folder.

Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92
mrvux
  • 8,523
  • 1
  • 27
  • 61
2

YOu can try this:-

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

 string directory= Path.GetDirectoryName( path1 );
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331