how to determine the directory from where app is loaded

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

    how to determine the directory from where app is loaded

    Hi,

    How can I determine the directory from which my app is started. Since upon
    installation the user can decide in which directory to install the file...I
    want to be able to load a file from a directory within that install
    directory no matter what it is.
    How best to deal with this?

    Tx.


  • Frank Oquendo

    #2
    Re: how to determine the directory from where app is loaded

    dawn wrote:
    [color=blue]
    > How best to deal with this?[/color]

    string path =
    System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location;
    System.IO.FileI nfo info = new System.IO.FileI nfo(path);
    Console.WriteLi ne(info.Directo ryName);

    --
    There are 10 kinds of people. Those who understand binary and those who
    don't.


    (Pull the pin to reply)


    Comment

    • Michael Culley

      #3
      Re: how to determine the directory from where app is loaded

      another method

      System.Diagnost ics.Process.Get CurrentProcess( ).MainModule.Fi leName;


      --
      Michael Culley


      "Frank Oquendo" <frankopin@acad x.com> wrote in message news:egUVQJLqDH A.1960@TK2MSFTN GP12.phx.gbl...[color=blue]
      > dawn wrote:
      >[color=green]
      > > How best to deal with this?[/color]
      >
      > string path =
      > System.Reflecti on.Assembly.Get ExecutingAssemb ly().Location;
      > System.IO.FileI nfo info = new System.IO.FileI nfo(path);
      > Console.WriteLi ne(info.Directo ryName);
      >
      > --
      > There are 10 kinds of people. Those who understand binary and those who
      > don't.
      >
      > http://code.acadx.com
      > (Pull the pin to reply)
      >
      >[/color]


      Comment

      • Jon

        #4
        Re: how to determine the directory from where app is loaded

        What about this:
        Environment.Com mandLine[0];


        [AllAmericanJobs - Searching jobs from your desktop and automatically
        sends resume.]
        ---------------------------------------------------------




        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Glenn B

          #5
          Re: how to determine the directory from where app is loaded

          Environment.Cur rentDirectory

          Gets and sets the fully qualified path of the current directory; that is,
          the directory from which this process starts.

          HTH

          Glenn

          This will return the directory

          "dawn" <dawn4715@hotma il.com> wrote in message
          news:_Cesb.1891 6$X_3.479343@ph obos.telenet-ops.be...[color=blue]
          > Hi,
          >
          > How can I determine the directory from which my app is started. Since upon
          > installation the user can decide in which directory to install the[/color]
          file...I[color=blue]
          > want to be able to load a file from a directory within that install
          > directory no matter what it is.
          > How best to deal with this?
          >
          > Tx.
          >
          >[/color]


          Comment

          • Michael Culley

            #6
            Re: how to determine the directory from where app is loaded

            "Jon" <anonymous@devd ex.com> wrote in message news:Ot47N0NqDH A.2940@TK2MSFTN GP09.phx.gbl...[color=blue]
            > What about this:
            > Environment.Com mandLine[0];[/color]

            I guess it's great if you want a single " :-)

            --
            Michael Culley


            Comment

            • Matthew Slyh

              #7
              Re: how to determine the directory from where app is loaded

              I thought that Application.Sta rtupPath gave us this information... Am I
              missing something?


              "Jon" <anonymous@devd ex.com> wrote in message
              news:Ot47N0NqDH A.2940@TK2MSFTN GP09.phx.gbl...[color=blue]
              > What about this:
              > Environment.Com mandLine[0];
              >
              > http://www.naptaxes.com/AAJ/
              > [AllAmericanJobs - Searching jobs from your desktop and automatically
              > sends resume.]
              > ---------------------------------------------------------
              >
              >
              >
              >
              > *** Sent via Developersdex http://www.developersdex.com ***
              > Don't just participate in USENET...get rewarded for it![/color]


              Comment

              Working...