Guid ID = Guid.Parse("d0094166-e435-4a8f-a02e-3167a4550be7");
string str = ID.ToString();
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add("Default", str);
config.Save();
txtTest.Text = System.Configuration.ConfigurationManager.AppSettings["Default"];
运行bin文件夹中的.exe 后 对应的配置文件的结果:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<appSettings>
<add key="Default" value="d0094166-e435-4a8f-a02e-3167a4550be7" />
</appSettings>
</configuration>
自动生成 default和对应的value