The user's input is saved in the configuration file of the application because at every restart the software needs to use this input:
public void setAppSetting(string key, string value)
{
//Laden der AppSettings
Configuration config = ConfigurationManager.
OpenExeConfiguration(
System.Reflection.Assembly.
GetExecutingAssembly().Location);
if (config.AppSettings.Settings[key] != null)
{
config.AppSettings.Settings.Remove(key);
}
config.AppSettings.Settings.Add(key, value);
config.Save(ConfigurationSaveMode.Modified);
}
public string getAppSetting(string key)
{
Configuration config = ConfigurationManager.
OpenExeConfiguration(
System.Reflection.Assembly.
GetExecutingAssembly().Location);
return config.AppSettings.Settings[key].Value;
}
Load of the app settings:
private void Start_Closed(object sender, EventArgs e)
{
setAppSetting("benutzerEingabe", textBoxPath.Text);
setAppSetting("benutzerEingabe", userConfigurePath);
}
So when the user decrompess the zip file where the exe file exists there is the content file without a content. So I want it.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
After the first use of the app the config is filled with the key:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="benutzerEingabe" />
</appSettings>
</configuration>
The problem for me is when the user copies the exe to an other place and start the first time this app there is a new config file. That's the problem. Is there any possibility that the config file is implement in the exe file so that this file isn't create itself. Or is there any other solution?