Reputation: 41128
I have the following code that determines if it's the first time the user opens the app. If it is, a file dialog shows, and then it's supposed to change the setting to false, so it doesn't happen after that one time.
public void VerifyIfFirstTimeRun()
{
if (Properties.Settings.Default.FirstTimeUse == true)
{
LocateWoWFolder();
Properties.Settings.Default.FirstTimeUse = false;
}
}
In the last line, I receive the following error:
Error 1 Property or indexer 'CDLauncher.Properties.Settings.FirstTimeUse' cannot be assigned to -- it is read only
How can I do this?
Upvotes: 1
Views: 1633
Reputation: 41128
I found out you can indeed change the .settings at run-time, but only setting in the "User" scope.
So if you're trying to make a setting that does X only when the first time the app opens, you can do the following:
public void VerifyIfFirstTimeRun()
{
if (Properties.Settings.Default.FirstTimeUse == true)
{
//Do something here.
//Change first time usage Bool to false
Properties.Settings.Default.FirstTimeUse = false;
//Save your changes, and you're done!
Properties.Settings.Default.Save();
}
}
Upvotes: 3
Reputation: 292345
The scope of your setting is probably set to Application. Set it to User, you will be able to modify it.
Upvotes: 3