Best way to get application folder path

前端 未结 10 2173
無奈伤痛
無奈伤痛 2020-11-22 02:03

I see that there are some ways to get the application folder path:

  1. Application.StartupPath
  2. System.IO.Path.GetDirectoryName( System.
10条回答
  •  清酒与你
    2020-11-22 02:43

    I started a process from a Windows Service over the Win32 API in the session from the user which is actually logged in (in Task Manager session 1 not 0). In this was we can get to know, which variable is the best.

    For all 7 cases from the question above, the following are the results:

    Path1: C:\Program Files (x86)\MyProgram
    Path2: C:\Program Files (x86)\MyProgram
    Path3: C:\Program Files (x86)\MyProgram\
    Path4: C:\Windows\system32
    Path5: C:\Windows\system32
    Path6: file:\C:\Program Files (x86)\MyProgram
    Path7: C:\Program Files (x86)\MyProgram
    

    Perhaps it's helpful for some of you, doing the same stuff, when you search the best variable for your case.

提交回复
热议问题