By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,444 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

from within an assembly, How to get its name and path?

P: n/a
Hello,

What is the easiest (and cleanest) way to get from within an assembly
information such as assembly path and name.

eg:
current assembly is:
C:\temp\blabla.dll

I just want to get this "C:\temp\blabla.dll" string back.
Thanks,
José
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Jon,

As always you're really quick :-)

Thanks,
José
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ...
José Joye <jo*******@KILLTHESPAMSbluewin.ch> wrote:
What is the easiest (and cleanest) way to get from within an assembly
information such as assembly path and name.

eg:
current assembly is:
C:\temp\blabla.dll

I just want to get this "C:\temp\blabla.dll" string back.


Assembly.GetExecutingAssembly().CodeBase;

That will give it as file:///c:/temp/blabla.dll - you can check for and
strip off the file:/// though if you want. (Don't forget that the
assembly may not have been loaded from disk.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

Jul 19 '05 #2

P: n/a
Assembly.GetExecutingAssembly().CodeBase;


I'd use Assembly.GetExecutingAssembly().Location instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Jul 19 '05 #3

P: n/a
Use:

Assembly.GetExecutingAssembly().Location

-------------------------
"Manish Agarwal"- <ma***********@hotmail.com>

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
Hello,

What is the easiest (and cleanest) way to get from within an assembly
information such as assembly path and name.

eg:
current assembly is:
C:\temp\blabla.dll

I just want to get this "C:\temp\blabla.dll" string back.
Thanks,
José

Jul 19 '05 #4

P: n/a
Mattias Sjögren <ma********************@mvps.org> wrote:
Assembly.GetExecutingAssembly().CodeBase;


I'd use Assembly.GetExecutingAssembly().Location instead.


Yup, that is indeed a better way.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.