Get File Spec of Current DLL

  • Thread starter Thread starter News
  • Start date Start date
N

News

Does anyone know how to get the file spec of DLL from within the code?

I thought that System.Reflection.GetExecutingAssembly() would work, but
it returns the name of the program that called DLL routine, not the DLL
file itself.

Mike Buchanan
 
This question is related to another question I had posted in another
group asking about dragging along folders when a DLL is built.

My DLL logic uses XML and SQL script files that are stored in
subfolders under the folder where the actual .DLL is located. For
example the XML files will always be in a folder named "TxnXML". So, I
guess what I really want is the folder where the .DLL file is located.

I'd like to write some code in the .DLL that can open files regardless
of where the .DLL is installed. I've tried using a relative path such
as:

oXMLDoc.Load ("..\TxnXml\MyDoc.xml");

and I've also tried to get the current location using
System.Reflection.GetExecutingAssembly().

In both cases the path is based on the calling program and not the
actual DLL.
 
Assembly.GetExecutingAssembly() will get the name of the assembly in which
the current code is executing. Once you snag the assembly reference, you can
use instance methods of the Assembly class to get the location of the
assembly.
 
Back
Top