Should I use AppDomain.CurrentDomain.BaseDirectory or System.Environment.CurrentDirectory?

前端 未结 7 1547
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 04:28

I have two exe files in the same folder, I can run exe2 from a button in exe1. Today I was observing a customer over a remote (terminal services) session and exe2 failed to

相关标签:
7条回答
  • 2020-11-28 05:24

    If you want to find files in the same directory as your application, AppDomain.CurrentDomain.BaseDirectory is the correct choice.

    Environment.CurrentDirectory is a value that can and will change throught the course of running your application. For instance, using default parameters, the OpenFileDialog in WinForms will change this value to the directory where the file was selected from.

    0 讨论(0)
提交回复
热议问题