Environment.CurrentDirectory is yielding unexpected results when running installed app

前端 未结 5 1940
既然无缘
既然无缘 2020-12-06 10:49

Background:

I built an installer for my app, and all my dll\'s and content files are getting correctly copied to the C:\\Program Files\\MyComp

5条回答
  •  醉话见心
    2020-12-06 11:11

    When a program is started, the current directory is typically the same as the one of the starting application, unless the starting application specifies a different working directory. It can really be anywhere on disk.

    In your case, the starting application is the shell (explorer.exe) in both cases. It does specify a working directory when starting a program, depending on the context of the launch. You have seen two different cases (double-clicking on a file in explorer, and running from the start menu); you have also found what Microsoft considers the most sensible values for current directory in either case: the user's home directory, and the directory that is shown in explorer (respectively).

提交回复
热议问题