469,352 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

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

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
4 20923
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
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
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
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.

Similar topics

7 posts views Thread by Robert W. | last post: by
7 posts views Thread by rfinch | last post: by
6 posts views Thread by HONOREDANCESTOR | last post: by
9 posts views Thread by =?Utf-8?B?VGhvbWFzIFcuIEJyb3du?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.