Question

I would like to maintain a list of all of the strings entered into a ComboBox across all uses of an application on a given PC, for use as the AutoCompleteSource for that ComboBox, i.e., I enter in "Fred" in the ComboBox, commit the data, close the application, reopen the application, reopen the ComboBox, type "F", receive the suggestion "Fred".

Assuming I already have in place code to create and maintain such a list in memory and add new elements to it as they are entered into the ComboBox, etc., what do you suggest as the best way to save/load this data in between sessions?

Possible complicating factors: This application will be deployed via OneClick deployment, and will search for updates online every time the application starts. I would prefer that if the application updates, the list still exists after the update has completed.

Thanks for your help.

Was it helpful?

Solution

Depending on your access level, storing them in a flat file seems the easiest choice.

  • To read the list of options, read the file and return an empty list if it isn't there.
  • To add an item, create the file if it isn't there and then append the option.

That means you don't send an empty file with your updates, so the data survives.

It appears that you could put the file in the Data Directory or use Isolated Storage.

OTHER TIPS

I would simply use the built in User Settings (My Project > Settings > Pick "User" for the scope of the setting); they are extremely easy to retrieve and update. And although I haven't done extensive testing, I believe they remain through application updates.

Does your application use a database? If so, that would be another option for permanent storage.

Edit
If you decide to go with the User Settings option, here is a new question that addresses an issue with those settings and ClickOnce.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top