【C#遗补】获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPath的区别

.Net Framework中,System.IO.Directory.GetCurrentDirectory()方法用于获得应用程序当前工作目录

如果使用此方法获得应用程序所在的目录,应该注意:System.IO.Directory.GetCurrentDirectory()方法获得的目录路径随着OpenFileDialog、SaveFileDialog等对象所确定的目录而改变(切换工作目录)

一般情况下,应该使用System.Windows.Forms.Application.StartupPath或System.AppDomain.CurrentDomain.BaseDirectory来获得应用程序所在的目录