The difference is explained in the ultimate .NET config resource - Cracking the Mysteries of .NET 2.0 Configuration:
OpenExeConfiguration (String)
will append ".config" to the filename
you provide and load that
configuration file. It's important to
note that OpenExeConfiguration(string
exePath) is a very misleading method,
as the filename does not have to be
the filename of the .exe that is
running [...]
By providing a filename other than the
EXE filename, an alternate *.config
file can be opened.
OpenExeConfiguration (ConfigurationUserLevel)
The second method,
OpenExeConfiguration(ConfigurationUserLevel
level) will load the appropriate
configuration file for the specified
configuration level. Configuration
levels, available in the Exe context,
allow you to specify whether you want
exe, roaming user, or local user
configuration [...] Remember that configuration is hierarchical and merged. When requesting roaming or local user configuration, that level up through machine.config are merged, resulting in the complete configuration accessible by your application for the given user level.
OpenMappedExeConfiguration(), OpenMappedMachineConfiguration()
Unlike the OpenExeConfiguration()
methods, which make several
assumptions about where your
configuration files reside,
OpenMappedExeConfiguration() and
OpenMappedMachineConfiguration() allow
you to explicitly specify where your
*.config files reside on disk. Using these methods, you can load an
alternate machine.config, load
User.config files from the locations
of your own choosing (vs. letting the
.NET framework decide on some
convoluted path), etc. When accessing
machine.config, a custom version is
not required,
OpenMachineConfiguration() should be
used instead.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…