471,334 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

Get File Spec of Current DLL

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

Dec 13 '05 #1
3 1773
Mike,

What do you mean by the file spec?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<Ne**@InsightfulMES.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
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

Dec 13 '05 #2
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.

Dec 14 '05 #3
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.

Ne**@InsightfulMES.com wrote:
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.


--
http://jaysonknight.com

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200512/1
Dec 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Andrew Slentz | last post: by
11 posts views Thread by Grim Reaper | last post: by
68 posts views Thread by Martin Joergensen | last post: by
1 post views Thread by Martin Pöpping | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.