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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • José Joye

    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é


  • José Joye

    #2
    Re: from within an assembly, How to get its name and path?

    Jon,

    As always you're really quick :-)

    Thanks,
    José
    "Jon Skeet" <skeet@pobox.co m> wrote in message
    news:MPG.19b58a cbff18ebef98a39 e@news.microsof t.com...[color=blue]
    > José Joye <jose.joye@KILL THESPAMSbluewin .ch> wrote:[color=green]
    > > 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.[/color]
    >
    > Assembly.GetExe cutingAssembly( ).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 - <skeet@pobox.co m>
    > http://www.pobox.com/~skeet/
    > If replying to the group, please do not mail me too[/color]


    Comment

    • Mattias Sjögren

      #3
      Re: from within an assembly, How to get its name and path?

      [color=blue]
      >Assembly.GetEx ecutingAssembly ().CodeBase;[/color]

      I'd use Assembly.GetExe cutingAssembly( ).Location instead.



      Mattias

      --
      Mattias Sjögren [MVP] mattias @ mvps.org

      Please reply only to the newsgroup.

      Comment

      • Manish Agarwal

        #4
        Re: from within an assembly, How to get its name and path?

        Use:

        Assembly.GetExe cutingAssembly( ).Location

        -------------------------
        "Manish Agarwal"- <manishkrishan@ hotmail.com>

        "José Joye" <jose.joye@KILL THESPAMSbluewin .ch> wrote in message
        news:OyiVNN#aDH A.1940@TK2MSFTN GP10.phx.gbl...[color=blue]
        > 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é
        >
        >[/color]


        Comment

        • Jon Skeet

          #5
          Re: from within an assembly, How to get its name and path?

          Mattias Sjögren <mattias.dont.w ant.spam@mvps.o rg> wrote:[color=blue][color=green]
          > >Assembly.GetEx ecutingAssembly ().CodeBase;[/color]
          >
          > I'd use Assembly.GetExe cutingAssembly( ).Location instead.[/color]

          Yup, that is indeed a better way.

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          Working...