Environment.CurrentDirectory is yielding unexpected results when running installed app

前端 未结 5 1932
既然无缘
既然无缘 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:16

    Use Application.StartupPath instead of Environment.CurrentDirectory.
    I've had a similar problem, where the CurrentDirectory was being changed inadvertently by something like an OpenFileDialog without me even realizing it.
    In your case, it sounds like the process that you're starting the application form is changing the CurrentDirectory unbeknownst to you.

提交回复
热议问题