After using the OpenFileDialog for selecting a file the Environment.CurrentDirectory changes to the folder of the file. Is this normal?
From my understanding Environment.CurrentDirectory should always be the application folder.
看一下
AppDomain.CurrentDomain.BaseDirectory和Environment.CurrentDirectory的区别
有什么不同之处?
- AppDomain.CurrentDomain.BaseDirectory
- Environment.CurrentDirectory
- AppDomainSetup.ApplicationBase
1和3基本相同.区别在于AppDomainSetup.ApplicationBase是可写的,但AppDomain.BaseDirectory是只读的,因为在创建appdomain后无法更改它.
2是完全不同的东西.它用于解决相对路径等问题.您可以随时在代码中更改CurrentDirectory,也可以通过FileDialogs之类的内容进行更改.