How to get Application Path?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frank Rizzo

    #1

    How to get Application Path?

    How to get Application Path?

    I can't really use
    System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetName(). CodeBase

    because it returns the path in the file://c/winnt/.../filename.exe
    format, which I can't really use to open files, etc...

    I also don't want to use System.Windows. Forms.Applicati on.ExecutablePa th
    because I don't want to include Windows Forms for my console app.

    Thanks

  • Champika Nirosh

    #2
    Re: How to get Application Path?

    Hi,

    Use Application.Sta rtupPath

    Nirosh.

    "Frank Rizzo" <nospam@nospam. com> wrote in message
    news:eJwq8BoSDH A.3768@tk2msftn gp13.phx.gbl...[color=blue]
    > How to get Application Path?
    >
    > I can't really use
    > System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetName(). CodeBase
    >
    > because it returns the path in the file://c/winnt/.../filename.exe
    > format, which I can't really use to open files, etc...
    >
    > I also don't want to use System.Windows. Forms.Applicati on.ExecutablePa th
    > because I don't want to include Windows Forms for my console app.
    >
    > Thanks
    >[/color]


    Comment

    • Eliyahu Goldin

      #3
      Re: How to get Application Path?

      Try Win32 API function GetCommandLine( ). It should return the command line
      with full application path. Sorry if it is not true, I don't have personal
      experience with that.

      Eliyahu

      "Frank Rizzo" <nospam@nospam. com> wrote in message
      news:eJwq8BoSDH A.3768@tk2msftn gp13.phx.gbl...[color=blue]
      > How to get Application Path?
      >
      > I can't really use
      > System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetName(). CodeBase
      >
      > because it returns the path in the file://c/winnt/.../filename.exe
      > format, which I can't really use to open files, etc...
      >
      > I also don't want to use System.Windows. Forms.Applicati on.ExecutablePa th
      > because I don't want to include Windows Forms for my console app.
      >
      > Thanks
      >[/color]


      Comment

      • Mikael

        #4
        Re: How to get Application Path?

        Have you tried System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location

        /Mikael

        "Frank Rizzo" <nospam@nospam. com> skrev i meddelandet
        news:eJwq8BoSDH A.3768@tk2msftn gp13.phx.gbl...[color=blue]
        > How to get Application Path?
        >
        > I can't really use
        > System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetName(). CodeBase
        >
        > because it returns the path in the file://c/winnt/.../filename.exe
        > format, which I can't really use to open files, etc...
        >
        > I also don't want to use System.Windows. Forms.Applicati on.ExecutablePa th
        > because I don't want to include Windows Forms for my console app.
        >
        > Thanks
        >[/color]


        Comment

        • Selvin

          #5
          Re: How to get Application Path?

          > Environment.Cur rentDirectory

          ??

          run cmd.exe
          cd c:\
          run prog for example
          c:\winnt\prog.e xe
          if try write Environment.Cur rentDirectory

          it return "c:\"




          --
          Selvin - Przemek Sulikowski
          selvin@osadkows ki.com.pl


          Comment

          • Champika Nirosh

            #6
            Re: How to get Application Path?

            Sorry I got busy with my office work so I didn't saw this

            ............... .., (You yourself fill the blank with the suitable word)

            Yes I read to the end of the post and I understood it and bellow is how I ask you to do, though your small brain cannot get it.

            Application.Sta rupPath doesn't use Windows Forms nore it return the path as file://c/winnt/.../filename.exe where you cannot use for file loading etc..
            It will return the path in a way, which you can create a FileInfo object and use to get almost all the details you need such as directory, directoryName, File Name, Full Path etc,,,,,,,,,,,, ,,,,

            Other than that it will give the actual path even if you load the assembly using a Shoutcut icon.

            Nirosh.


            "Frank Rizzo" <nospam@nospam. com> wrote in message news:u6IeEZpSDH A.1552@TK2MSFTN GP10.phx.gbl...[color=blue]
            > Dude,
            >
            > Did you read the post to the end?
            >
            > Champika Nirosh wrote:[color=green]
            > > Hi,
            > >
            > > Use Application.Sta rtupPath
            > >
            > > Nirosh.
            > >
            > > "Frank Rizzo" <nospam@nospam. com> wrote in message
            > > news:eJwq8BoSDH A.3768@tk2msftn gp13.phx.gbl...
            > > [color=darkred]
            > >>How to get Application Path?
            > >>
            > >>I can't really use
            > >>System.Reflec tion.Assembly.G etExecutingAsse mbly().GetName( ).CodeBase
            > >>
            > >>because it returns the path in the file://c/winnt/.../filename.exe
            > >>format, which I can't really use to open files, etc...
            > >>
            > >>I also don't want to use System.Windows. Forms.Applicati on.ExecutablePa th
            > >>because I don't want to include Windows Forms for my console app.[/color][/color]
            > [/color]

            Comment

            Working...