Before yesterday, I always thought that the Environment.currentDirectory property value always refers to the directory where the current application file is located until it is awakened by the FilenotFoundException. In MSDN, the CurrentDirectory property is described as: a fully qualified path for obtaining and setting the current directory (ie, the directory started from the process).
By debugging, FileOpendIalog will change the value of the current directory. When the user selects the file through the file, the value of the current directory will turn into the directory where the user is selected. So if you rely on this property to locate a fixed file location, then you want to disturb D by FilenotFoundException. If you need to always locate the location where the current application is located, you can get it with System.Windows.Forms.Application.StartupPath, and you can also use system.reflection.assembly.GeTEntryassembly (). Location to get the current entry / main thread The path to the collection file (including the file name), if only the string of the directory section, you can use System.io.path.getDirectoryName () to intercept.